mpeg4videodec: move MpegEncContext.shape to Mpeg4DecContext

This commit is contained in:
Anton Khirnov 2013-11-26 11:23:16 +01:00
parent 35e0833d41
commit ee8af2dd99
7 changed files with 39 additions and 30 deletions

View File

@ -442,9 +442,9 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->avctx->extradata_size);
if (ret < 0)
return ret;
ff_mpeg4_decode_picture_header(s, &gb);
ff_mpeg4_decode_picture_header(avctx->priv_data, &gb);
}
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {

View File

@ -235,7 +235,7 @@ int ff_h263_resync(MpegEncContext *s){
if(show_bits(&s->gb, 16)==0){
pos= get_bits_count(&s->gb);
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
ret= ff_mpeg4_decode_video_packet_header(s);
ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
else
ret= h263_decode_gob_header(s);
if(ret>=0)
@ -252,7 +252,7 @@ int ff_h263_resync(MpegEncContext *s){
pos= get_bits_count(&s->gb);
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
ret= ff_mpeg4_decode_video_packet_header(s);
ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
else
ret= h263_decode_gob_header(s);
if(ret>=0)

View File

@ -61,6 +61,8 @@
typedef struct Mpeg4DecContext {
MpegEncContext m;
int shape;
} Mpeg4DecContext;
/* dc encoding for mpeg4 */
@ -98,7 +100,7 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n,
void ff_set_mpeg4_time(MpegEncContext *s);
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
int ff_mpeg4_decode_picture_header(MpegEncContext *s, GetBitContext *gb);
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb);
void ff_mpeg4_encode_video_packet_header(MpegEncContext *s);
void ff_mpeg4_clean_buffers(MpegEncContext *s);
void ff_mpeg4_stuffing(PutBitContext *pbc);
@ -107,7 +109,7 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s);
void ff_clean_mpeg4_qscales(MpegEncContext *s);
int ff_mpeg4_decode_partitions(MpegEncContext *s);
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
int ff_mpeg4_decode_video_packet_header(MpegEncContext *s);
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx);
void ff_mpeg4_init_direct_mv(MpegEncContext *s);
/**

View File

@ -86,11 +86,11 @@ static int av_mpeg4_decode_header(AVCodecParserContext *s1,
if (avctx->extradata_size && pc->first_picture) {
init_get_bits(gb, avctx->extradata, avctx->extradata_size * 8);
ret = ff_mpeg4_decode_picture_header(s, gb);
ret = ff_mpeg4_decode_picture_header(dec_ctx, gb);
}
init_get_bits(gb, buf, 8 * buf_size);
ret = ff_mpeg4_decode_picture_header(s, gb);
ret = ff_mpeg4_decode_picture_header(dec_ctx, gb);
if (s->width && (!avctx->width || !avctx->height ||
!avctx->coded_width || !avctx->coded_height)) {
ret = ff_set_dimensions(avctx, s->width, s->height);

View File

@ -368,8 +368,10 @@ static int mpeg4_decode_sprite_trajectory(MpegEncContext *s, GetBitContext *gb)
* Decode the next video packet.
* @return <0 if something went wrong
*/
int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
{
MpegEncContext *s = &ctx->m;
int mb_num_bits = av_log2(s->mb_num - 1) + 1;
int header_extension = 0, mb_num, len;
@ -386,7 +388,7 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
return -1;
}
if (s->shape != RECT_SHAPE) {
if (ctx->shape != RECT_SHAPE) {
header_extension = get_bits1(&s->gb);
// FIXME more stuff here
}
@ -414,13 +416,13 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
s->mb_x = mb_num % s->mb_width;
s->mb_y = mb_num / s->mb_width;
if (s->shape != BIN_ONLY_SHAPE) {
if (ctx->shape != BIN_ONLY_SHAPE) {
int qscale = get_bits(&s->gb, s->quant_precision);
if (qscale)
s->chroma_qscale = s->qscale = qscale;
}
if (s->shape == RECT_SHAPE)
if (ctx->shape == RECT_SHAPE)
header_extension = get_bits1(&s->gb);
if (header_extension) {
@ -436,7 +438,7 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
skip_bits(&s->gb, 2); /* vop coding type */
// FIXME not rect stuff here
if (s->shape != BIN_ONLY_SHAPE) {
if (ctx->shape != BIN_ONLY_SHAPE) {
skip_bits(&s->gb, 3); /* intra dc vlc threshold */
// FIXME don't just ignore everything
if (s->pict_type == AV_PICTURE_TYPE_S &&
@ -1652,8 +1654,9 @@ static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb)
return 0;
}
static int decode_vol_header(MpegEncContext *s, GetBitContext *gb)
static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int width, height, vo_ver_id;
/* vol header */
@ -1699,10 +1702,10 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb)
s->low_delay = 0;
}
s->shape = get_bits(gb, 2); /* vol shape */
if (s->shape != RECT_SHAPE)
ctx->shape = get_bits(gb, 2); /* vol shape */
if (ctx->shape != RECT_SHAPE)
av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if (s->shape == GRAY_SHAPE && vo_ver_id != 1) {
if (ctx->shape == GRAY_SHAPE && vo_ver_id != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4); /* video_object_layer_shape_extension */
}
@ -1729,8 +1732,8 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb)
s->t_frame = 0;
if (s->shape != BIN_ONLY_SHAPE) {
if (s->shape == RECT_SHAPE) {
if (ctx->shape != BIN_ONLY_SHAPE) {
if (ctx->shape == RECT_SHAPE) {
skip_bits1(gb); /* marker */
width = get_bits(gb, 13);
skip_bits1(gb); /* marker */
@ -2038,8 +2041,9 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb)
return 0;
}
static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int time_incr, time_increment;
s->pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I; /* pict type: I = 0 , P = 1 */
@ -2134,7 +2138,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
return FRAME_SKIPPED;
}
if (s->shape != BIN_ONLY_SHAPE &&
if (ctx->shape != BIN_ONLY_SHAPE &&
(s->pict_type == AV_PICTURE_TYPE_P ||
(s->pict_type == AV_PICTURE_TYPE_S &&
s->vol_sprite_usage == GMC_SPRITE))) {
@ -2145,7 +2149,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
}
// FIXME reduced res stuff
if (s->shape != RECT_SHAPE) {
if (ctx->shape != RECT_SHAPE) {
if (s->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
skip_bits(gb, 13); /* width */
skip_bits1(gb); /* marker */
@ -2163,7 +2167,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
// FIXME complexity estimation stuff
if (s->shape != BIN_ONLY_SHAPE) {
if (ctx->shape != BIN_ONLY_SHAPE) {
skip_bits_long(gb, s->cplx_estimation_trash_i);
if (s->pict_type != AV_PICTURE_TYPE_I)
skip_bits_long(gb, s->cplx_estimation_trash_p);
@ -2202,7 +2206,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
}
if (s->shape != BIN_ONLY_SHAPE) {
if (ctx->shape != BIN_ONLY_SHAPE) {
s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision);
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR,
@ -2241,7 +2245,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
}
if (!s->scalability) {
if (s->shape != RECT_SHAPE && s->pict_type != AV_PICTURE_TYPE_I)
if (ctx->shape != RECT_SHAPE && s->pict_type != AV_PICTURE_TYPE_I)
skip_bits1(gb); // vop shape coding type
} else {
if (s->enhancement_type) {
@ -2282,8 +2286,9 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
* FRAME_SKIPPED if a not coded VOP is found
* 0 if a VOP is found
*/
int ff_mpeg4_decode_picture_header(MpegEncContext *s, GetBitContext *gb)
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
unsigned startcode, v;
/* search next start code */
@ -2373,7 +2378,7 @@ int ff_mpeg4_decode_picture_header(MpegEncContext *s, GetBitContext *gb)
}
if (startcode >= 0x120 && startcode <= 0x12F) {
if (decode_vol_header(s, gb) < 0)
if (decode_vol_header(ctx, gb) < 0)
return -1;
} else if (startcode == USER_DATA_STARTCODE) {
decode_user_data(s, gb);
@ -2394,7 +2399,7 @@ end:
s->low_delay = 1;
s->avctx->has_b_frames = !s->low_delay;
return decode_vop_header(s, gb);
return decode_vop_header(ctx, gb);
}
static int mpeg4_update_thread_context(AVCodecContext *dst,
@ -2408,6 +2413,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
if (ret < 0)
return ret;
s->shape = s1->shape;
return 0;
}

View File

@ -717,7 +717,8 @@ do {\
// MPEG4 timing info
memcpy(&s->time_increment_bits, &s1->time_increment_bits,
(char *) &s1->shape - (char *) &s1->time_increment_bits);
(char *) &s1->pb_field_time + sizeof(s1->pb_field_time) -
(char *) &s1->time_increment_bits);
// B-frame info
s->max_b_frames = s1->max_b_frames;

View File

@ -578,7 +578,6 @@ typedef struct MpegEncContext {
uint16_t pb_time; ///< time distance between the last b and p,s,i frame
uint16_t pp_field_time;
uint16_t pb_field_time; ///< like above, just for interlaced
int shape;
int vol_sprite_usage;
int sprite_width;
int sprite_height;