From cc05a45d339d57214d647f5e01e91491c78a0b24 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 19 Oct 2011 09:25:52 +0200 Subject: mpeg12: move Mpeg1Context from mpeg12.c to mpeg12.h It will be used in vdpau code. --- libavcodec/mpeg12.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libavcodec/mpeg12.h') diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index 4c55726160..b71ad5df7f 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -30,6 +30,19 @@ extern VLC ff_dc_lum_vlc; extern VLC ff_dc_chroma_vlc; +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 */ + int slice_count; + int swap_uv;//indicate VCR2 + int save_aspect_info; + int save_width, save_height, save_progressive_seq; + AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator + int sync; ///< Did we reach a sync point like a GOP/SEQ/KEYFrame? +} Mpeg1Context; + extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; void ff_mpeg12_common_init(MpegEncContext *s); -- cgit v1.2.3 From da22ba7df461c13bf0b0eabc953303803a285d91 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 19 Oct 2011 09:28:45 +0200 Subject: mpeg12: move full_pel from MpegEncContext to Mpeg1Context It's MPEG-1 specific. --- libavcodec/mpeg12.c | 15 ++++++++------- libavcodec/mpeg12.h | 1 + libavcodec/mpegvideo.h | 1 - libavcodec/vdpau.c | 7 ++++--- libavcodec/vdpau_internal.h | 3 ++- 5 files changed, 15 insertions(+), 12 deletions(-) (limited to 'libavcodec/mpeg12.h') diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 82dc53279f..63b6066f32 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -734,8 +734,9 @@ static void exchange_uv(MpegEncContext *s) #define MT_16X8 2 #define MT_DMV 3 -static int mpeg_decode_mb(MpegEncContext *s, DCTELEM block[12][64]) +static int mpeg_decode_mb(Mpeg1Context *s1, DCTELEM block[12][64]) { + MpegEncContext *s = &s1->mpeg_enc_ctx; int i, j, k, cbp, val, mb_type, motion_type; const int mb_block_count = 4 + (1 << s->chroma_format); @@ -909,7 +910,7 @@ static int mpeg_decode_mb(MpegEncContext *s, DCTELEM block[12][64]) s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]); /* full_pel: only for MPEG-1 */ - if (s->full_pel[i]) { + if (s1->full_pel[i]) { s->mv[i][0][0] <<= 1; s->mv[i][0][1] <<= 1; } @@ -1327,7 +1328,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, vbv_delay = get_bits(&s->gb, 16); if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) { - s->full_pel[0] = get_bits1(&s->gb); + s1->full_pel[0] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM)) return -1; @@ -1335,7 +1336,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, s->mpeg_f_code[0][1] = f_code; } if (s->pict_type == AV_PICTURE_TYPE_B) { - s->full_pel[1] = get_bits1(&s->gb); + s1->full_pel[1] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM)) return -1; @@ -1483,7 +1484,7 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) { MpegEncContext *s = &s1->mpeg_enc_ctx; - s->full_pel[0] = s->full_pel[1] = 0; + s1->full_pel[0] = s1->full_pel[1] = 0; s->mpeg_f_code[0][0] = get_bits(&s->gb, 4); s->mpeg_f_code[0][1] = get_bits(&s->gb, 4); s->mpeg_f_code[1][0] = get_bits(&s->gb, 4); @@ -1715,7 +1716,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) ff_xvmc_init_block(s); // set s->block - if (mpeg_decode_mb(s, s->block) < 0) + if (mpeg_decode_mb(s1, s->block) < 0) return -1; if (s->current_picture.f.motion_val[0] && !s->encoding) { // note motion_val is normally NULL unless we want to extract the MVs @@ -2258,7 +2259,7 @@ static int decode_chunks(AVCodecContext *avctx, } if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) - ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); + ff_vdpau_mpeg_picture_complete(s, buf, buf_size, s->slice_count); if (slice_end(avctx, picture)) { if (s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index b71ad5df7f..2a2049fea4 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -41,6 +41,7 @@ typedef struct Mpeg1Context { int save_width, save_height, save_progressive_seq; AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator int sync; ///< Did we reach a sync point like a GOP/SEQ/KEYFrame? + int full_pel[2]; } Mpeg1Context; extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index f00914c82c..0af5d8dfd4 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -634,7 +634,6 @@ typedef struct MpegEncContext { int chroma_y_shift; int progressive_frame; - int full_pel[2]; int interlaced_dct; int first_slice; int first_field; ///< is 1 for the first field of a field picture 0 otherwise diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index df04ca01fc..2a7894edd2 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -190,9 +190,10 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s) render->bitstream_buffers_used = 0; } -void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, +void ff_vdpau_mpeg_picture_complete(Mpeg1Context *s1, const uint8_t *buf, int buf_size, int slice_count) { + MpegEncContext *s = &s1->mpeg_enc_ctx; struct vdpau_render_state *render, *last, *next; int i; @@ -211,8 +212,8 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, render->info.mpeg.alternate_scan = s->alternate_scan; render->info.mpeg.q_scale_type = s->q_scale_type; render->info.mpeg.top_field_first = s->top_field_first; - render->info.mpeg.full_pel_forward_vector = s->full_pel[0]; // MPEG-1 only. Set 0 for MPEG-2 - render->info.mpeg.full_pel_backward_vector = s->full_pel[1]; // MPEG-1 only. Set 0 for MPEG-2 + render->info.mpeg.full_pel_forward_vector = s1->full_pel[0]; // MPEG-1 only. Set 0 for MPEG-2 + render->info.mpeg.full_pel_backward_vector = s1->full_pel[1]; // MPEG-1 only. Set 0 for MPEG-2 render->info.mpeg.f_code[0][0] = s->mpeg_f_code[0][0]; // For MPEG-1 fill both horiz. & vert. render->info.mpeg.f_code[0][1] = s->mpeg_f_code[0][1]; render->info.mpeg.f_code[1][0] = s->mpeg_f_code[1][0]; diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h index 673fd3349b..49f8e46a00 100644 --- a/libavcodec/vdpau_internal.h +++ b/libavcodec/vdpau_internal.h @@ -26,11 +26,12 @@ #include #include "mpegvideo.h" +#include "mpeg12.h" void ff_vdpau_add_data_chunk(MpegEncContext *s, const uint8_t *buf, int buf_size); -void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, +void ff_vdpau_mpeg_picture_complete(Mpeg1Context *s1, const uint8_t *buf, int buf_size, int slice_count); void ff_vdpau_h264_picture_start(MpegEncContext *s); -- cgit v1.2.3 From 3fc08304322ce3ed0e4a71efde78ae5e0d5c910c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 19 Oct 2011 09:28:45 +0200 Subject: mpeg12: move closed_gop from MpegEncContext to Mpeg1Context It's MPEG-1/2 specific. --- libavcodec/mpeg12.c | 7 ++++--- libavcodec/mpeg12.h | 1 + libavcodec/mpegvideo.c | 1 - libavcodec/mpegvideo.h | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libavcodec/mpeg12.h') diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 63b6066f32..6fb175e626 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2111,7 +2111,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx, time_code_seconds = get_bits(&s->gb, 6); time_code_pictures = get_bits(&s->gb, 6); - s->closed_gop = get_bits1(&s->gb); + s1->closed_gop = get_bits1(&s->gb); /*broken_link indicate that after editing the reference frames of the first B-Frames after GOP I-Frame are missing (open gop)*/ @@ -2120,7 +2120,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx, if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "GOP (%2d:%02d:%02d.[%02d]) closed_gop=%d broken_link=%d\n", time_code_hours, time_code_minutes, time_code_seconds, - time_code_pictures, s->closed_gop, broken_link); + time_code_pictures, s1->closed_gop, broken_link); } /** * Find the end of the current frame in the bitstream. @@ -2383,7 +2383,7 @@ static int decode_chunks(AVCodecContext *avctx, if (s2->last_picture_ptr == NULL) { /* Skip B-frames if we do not have reference frames and gop is not closed */ if (s2->pict_type == AV_PICTURE_TYPE_B) { - if (!s2->closed_gop) + if (!s->closed_gop) break; } } @@ -2467,6 +2467,7 @@ static void flush(AVCodecContext *avctx) Mpeg1Context *s = avctx->priv_data; s->sync=0; + s->closed_gop = 0; ff_mpeg_flush(avctx); } diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index 2a2049fea4..209bf05234 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -42,6 +42,7 @@ typedef struct Mpeg1Context { AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator int sync; ///< Did we reach a sync point like a GOP/SEQ/KEYFrame? int full_pel[2]; + int closed_gop; ///< GOP is closed } Mpeg1Context; extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index c1cd1f7a1d..effc9b7baf 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -2404,7 +2404,6 @@ void ff_mpeg_flush(AVCodecContext *avctx){ s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL; s->mb_x= s->mb_y= 0; - s->closed_gop= 0; s->parse_context.state= -1; s->parse_context.frame_start_found= 0; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 0af5d8dfd4..b69519a272 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -329,7 +329,6 @@ typedef struct MpegEncContext { int *lambda_table; int adaptive_quant; ///< use adaptive quantization int dquant; ///< qscale difference to prev qscale - int closed_gop; ///< MPEG1/2 GOP is closed int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ... int last_pict_type; //FIXME removes int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol -- cgit v1.2.3