comparison mpeg12.c @ 2219:9b6eb06cc184 libavcodec

mess cleanup
author michael
date Fri, 10 Sep 2004 18:54:02 +0000
parents edf4787f3baf
children 7e0b2e86afa9
comparison
equal deleted inserted replaced
2218:cff6c9b8ae57 2219:9b6eb06cc184
1912 int repeat_field; /* true if we must repeat the field */ 1912 int repeat_field; /* true if we must repeat the field */
1913 AVPanScan pan_scan; /** some temporary storage for the panscan */ 1913 AVPanScan pan_scan; /** some temporary storage for the panscan */
1914 int slice_count; 1914 int slice_count;
1915 int swap_uv;//indicate VCR2 1915 int swap_uv;//indicate VCR2
1916 int save_aspect_info; 1916 int save_aspect_info;
1917 AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator
1917 1918
1918 } Mpeg1Context; 1919 } Mpeg1Context;
1919 1920
1920 static int mpeg_decode_init(AVCodecContext *avctx) 1921 static int mpeg_decode_init(AVCodecContext *avctx)
1921 { 1922 {
1944 return 0; 1945 return 0;
1945 } 1946 }
1946 1947
1947 static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, 1948 static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
1948 const uint8_t *new_perm){ 1949 const uint8_t *new_perm){
1949 uint16_t temp_matrix[64]; 1950 uint16_t temp_matrix[64];
1950 int i; 1951 int i;
1951 1952
1952 memcpy(temp_matrix,matrix,64*sizeof(uint16_t)); 1953 memcpy(temp_matrix,matrix,64*sizeof(uint16_t));
1953 1954
1954 for(i=0;i<64;i++){ 1955 for(i=0;i<64;i++){
1955 matrix[new_perm[i]] = temp_matrix[old_perm[i]]; 1956 matrix[new_perm[i]] = temp_matrix[old_perm[i]];
1957 } 1958 }
1958 1959
1959 //Call this function when we know all parameters 1960 //Call this function when we know all parameters
1960 //it may be called in different places for mpeg1 and mpeg2 1961 //it may be called in different places for mpeg1 and mpeg2
1961 static int mpeg_decode_postinit(AVCodecContext *avctx){ 1962 static int mpeg_decode_postinit(AVCodecContext *avctx){
1962 Mpeg1Context *s1 = avctx->priv_data; 1963 Mpeg1Context *s1 = avctx->priv_data;
1963 MpegEncContext *s = &s1->mpeg_enc_ctx; 1964 MpegEncContext *s = &s1->mpeg_enc_ctx;
1964 uint8_t old_permutation[64]; 1965 uint8_t old_permutation[64];
1965
1966 1966
1967 if ( 1967 if (
1968 (s1->mpeg_enc_ctx_allocated == 0)|| 1968 (s1->mpeg_enc_ctx_allocated == 0)||
1969 avctx->width != s->width || 1969 avctx->width != s->width ||
1970 avctx->height != s->height|| 1970 avctx->height != s->height||
1999 }else{//mpeg2 1999 }else{//mpeg2
2000 //mpeg2 fps 2000 //mpeg2 fps
2001 av_reduce( 2001 av_reduce(
2002 &s->avctx->frame_rate, 2002 &s->avctx->frame_rate,
2003 &s->avctx->frame_rate_base, 2003 &s->avctx->frame_rate_base,
2004 frame_rate_tab[s->frame_rate_index].num * (s->frame_rate_ext_n+1), 2004 frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
2005 frame_rate_tab[s->frame_rate_index].den * (s->frame_rate_ext_d+1), 2005 frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
2006 1<<30); 2006 1<<30);
2007 //mpeg2 aspect 2007 //mpeg2 aspect
2008 if(s->aspect_ratio_info > 1){ 2008 if(s->aspect_ratio_info > 1){
2009 if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0) ){ 2009 if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0) ){
2010 s->avctx->sample_aspect_ratio= 2010 s->avctx->sample_aspect_ratio=
2129 s->c_dc_scale = 8; 2129 s->c_dc_scale = 8;
2130 s->first_slice = 1; 2130 s->first_slice = 1;
2131 return 0; 2131 return 0;
2132 } 2132 }
2133 2133
2134 static void mpeg_decode_sequence_extension(MpegEncContext *s) 2134 static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
2135 { 2135 {
2136 MpegEncContext *s= &s1->mpeg_enc_ctx;
2136 int horiz_size_ext, vert_size_ext; 2137 int horiz_size_ext, vert_size_ext;
2137 int bit_rate_ext; 2138 int bit_rate_ext;
2138 2139
2139 skip_bits(&s->gb, 1); /* profil and level esc*/ 2140 skip_bits(&s->gb, 1); /* profil and level esc*/
2140 s->avctx->profile= get_bits(&s->gb, 3); 2141 s->avctx->profile= get_bits(&s->gb, 3);
2151 s->avctx->rc_buffer_size += get_bits(&s->gb, 8)*1024*16<<10; 2152 s->avctx->rc_buffer_size += get_bits(&s->gb, 8)*1024*16<<10;
2152 2153
2153 s->low_delay = get_bits1(&s->gb); 2154 s->low_delay = get_bits1(&s->gb);
2154 if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1; 2155 if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;
2155 2156
2156 s->frame_rate_ext_n = get_bits(&s->gb, 2); 2157 s1->frame_rate_ext.num = get_bits(&s->gb, 2)+1;
2157 s->frame_rate_ext_d = get_bits(&s->gb, 5); 2158 s1->frame_rate_ext.den = get_bits(&s->gb, 5)+1;
2158 2159
2159 dprintf("sequence extension\n"); 2160 dprintf("sequence extension\n");
2160 s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO; 2161 s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
2161 s->avctx->sub_id = 2; /* indicates mpeg2 found */ 2162 s->avctx->sub_id = 2; /* indicates mpeg2 found */
2162 2163
2318 init_get_bits(&s->gb, buf, buf_size*8); 2319 init_get_bits(&s->gb, buf, buf_size*8);
2319 2320
2320 ext_type = get_bits(&s->gb, 4); 2321 ext_type = get_bits(&s->gb, 4);
2321 switch(ext_type) { 2322 switch(ext_type) {
2322 case 0x1: 2323 case 0x1:
2323 mpeg_decode_sequence_extension(s); 2324 mpeg_decode_sequence_extension(s1);
2324 break; 2325 break;
2325 case 0x2: 2326 case 0x2:
2326 mpeg_decode_sequence_display_extension(s1); 2327 mpeg_decode_sequence_display_extension(s1);
2327 break; 2328 break;
2328 case 0x3: 2329 case 0x3:
2336 break; 2337 break;
2337 } 2338 }
2338 } 2339 }
2339 2340
2340 static void exchange_uv(MpegEncContext *s){ 2341 static void exchange_uv(MpegEncContext *s){
2341 short * tmp; 2342 short * tmp = s->pblocks[4];
2342
2343 tmp = s->pblocks[4];
2344 s->pblocks[4] = s->pblocks[5]; 2343 s->pblocks[4] = s->pblocks[5];
2345 s->pblocks[5] = tmp; 2344 s->pblocks[5] = tmp;
2346 } 2345 }
2347 2346
2348 static int mpeg_field_start(MpegEncContext *s){ 2347 static int mpeg_field_start(MpegEncContext *s){