MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / mpeg1_decode_sequence

Function mpeg1_decode_sequence

libavcodec/mpeg12.c:1971–2047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1969}
1970
1971static int mpeg1_decode_sequence(AVCodecContext *avctx,
1972 const uint8_t *buf, int buf_size)
1973{
1974 Mpeg1Context *s1 = avctx->priv_data;
1975 MpegEncContext *s = &s1->mpeg_enc_ctx;
1976 int width,height;
1977 int i, v, j;
1978
1979 init_get_bits(&s->gb, buf, buf_size*8);
1980
1981 width = get_bits(&s->gb, 12);
1982 height = get_bits(&s->gb, 12);
1983 if (width <= 0 || height <= 0)
1984 return -1;
1985 s->aspect_ratio_info= get_bits(&s->gb, 4);
1986 if (s->aspect_ratio_info == 0) {
1987 av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n");
1988 if (avctx->error_recognition >= FF_ER_COMPLIANT)
1989 return -1;
1990 }
1991 s->frame_rate_index = get_bits(&s->gb, 4);
1992 if (s->frame_rate_index == 0 || s->frame_rate_index > 13)
1993 return -1;
1994 s->bit_rate = get_bits(&s->gb, 18) * 400;
1995 if (get_bits1(&s->gb) == 0) /* marker */
1996 return -1;
1997 s->width = width;
1998 s->height = height;
1999
2000 s->avctx->rc_buffer_size= get_bits(&s->gb, 10) * 1024*16;
2001 skip_bits(&s->gb, 1);
2002
2003 /* get matrix */
2004 if (get_bits1(&s->gb)) {
2005 load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
2006 } else {
2007 for(i=0;i<64;i++) {
2008 j = s->dsp.idct_permutation[i];
2009 v = ff_mpeg1_default_intra_matrix[i];
2010 s->intra_matrix[j] = v;
2011 s->chroma_intra_matrix[j] = v;
2012 }
2013 }
2014 if (get_bits1(&s->gb)) {
2015 load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
2016 } else {
2017 for(i=0;i<64;i++) {
2018 int j= s->dsp.idct_permutation[i];
2019 v = ff_mpeg1_default_non_intra_matrix[i];
2020 s->inter_matrix[j] = v;
2021 s->chroma_inter_matrix[j] = v;
2022 }
2023 }
2024
2025 if(show_bits(&s->gb, 23) != 0){
2026 av_log(s->avctx, AV_LOG_ERROR, "sequence header damaged\n");
2027 return -1;
2028 }

Callers 1

decode_chunksFunction · 0.85

Calls 7

init_get_bitsFunction · 0.85
get_bitsFunction · 0.85
av_logFunction · 0.85
get_bits1Function · 0.85
skip_bitsFunction · 0.85
load_matrixFunction · 0.85
show_bitsFunction · 0.85

Tested by

no test coverage detected