aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpeg12.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-10-20 09:52:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-10-20 09:52:02 +0000
commitfa384dcc8100ef973a702b9e5bc3236571c97750 (patch)
tree7e539a0d0de64b32417eee38c9c319389ff9d0f7 /libavcodec/mpeg12.c
parentf2fae326e3f2ef03aa1b1ba91153f82a7f2be5c8 (diff)
downloadffmpeg-fa384dcc8100ef973a702b9e5bc3236571c97750.tar.gz
export mpeg2 active display area / pan scan
fix mpeg2 aspect_ratio for the rare case that active display area != AVCodecContext.width/height decode sequence display extension & picture display extension Originally committed as revision 2401 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r--libavcodec/mpeg12.c60
1 files changed, 57 insertions, 3 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index a5e646d29f..015033bf36 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1655,6 +1655,7 @@ typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
+ AVPanScan pan_scan; /** some temporary storage for the panscan */
} Mpeg1Context;
static int mpeg_decode_init(AVCodecContext *avctx)
@@ -1781,6 +1782,53 @@ static void mpeg_decode_sequence_extension(MpegEncContext *s)
printf("profile: %d, level: %d \n", profile, level);
}
+static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
+{
+ MpegEncContext *s= &s1->mpeg_enc_ctx;
+ int color_description, w, h;
+
+ skip_bits(&s->gb, 3); /* video format */
+ color_description= get_bits1(&s->gb);
+ if(color_description){
+ skip_bits(&s->gb, 8); /* color primaries */
+ skip_bits(&s->gb, 8); /* transfer_characteristics */
+ skip_bits(&s->gb, 8); /* matrix_coefficients */
+ }
+ w= get_bits(&s->gb, 14);
+ skip_bits(&s->gb, 1); //marker
+ h= get_bits(&s->gb, 14);
+ skip_bits(&s->gb, 1); //marker
+
+ s1->pan_scan.width= 16*w;
+ s1->pan_scan.height=16*h;
+
+ if(mpeg2_aspect[s->aspect_ratio_info] < 0.0)
+ s->avctx->aspect_ratio*= (s->width * h)/(float)(s->height * w);
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO)
+ printf("sde w:%d, h:%d\n", w, h);
+}
+
+static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
+{
+ MpegEncContext *s= &s1->mpeg_enc_ctx;
+ int i;
+
+ for(i=0; i<1; i++){ //FIXME count
+ s1->pan_scan.position[i][0]= get_sbits(&s->gb, 16);
+ skip_bits(&s->gb, 1); //marker
+ s1->pan_scan.position[i][1]= get_sbits(&s->gb, 16);
+ skip_bits(&s->gb, 1); //marker
+ }
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO)
+ printf("pde (%d,%d) (%d,%d) (%d,%d)\n",
+ s1->pan_scan.position[0][0], s1->pan_scan.position[0][1],
+ s1->pan_scan.position[1][0], s1->pan_scan.position[1][1],
+ s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]
+ );
+}
+
static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
{
int i, v, j;
@@ -1881,15 +1929,18 @@ static void mpeg_decode_extension(AVCodecContext *avctx,
ext_type = get_bits(&s->gb, 4);
switch(ext_type) {
case 0x1:
- /* sequence ext */
mpeg_decode_sequence_extension(s);
break;
+ case 0x2:
+ mpeg_decode_sequence_display_extension(s1);
+ break;
case 0x3:
- /* quant matrix extension */
mpeg_decode_quant_matrix_extension(s);
break;
+ case 0x7:
+ mpeg_decode_picture_display_extension(s1);
+ break;
case 0x8:
- /* picture extension */
mpeg_decode_picture_coding_extension(s);
break;
}
@@ -1953,6 +2004,9 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s->current_picture_ptr->repeat_pict = 1;
}
}
+
+ *s->current_picture_ptr->pan_scan= s1->pan_scan;
+
//printf("%d\n", s->current_picture_ptr->repeat_pict);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){