Commit ad13b8ca authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ee8af2dd'

* commit 'ee8af2dd':
  mpeg4videodec: move MpegEncContext.shape to Mpeg4DecContext

Conflicts:
	libavcodec/h263dec.c
	libavcodec/mpeg4videodec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents be0b869b ee8af2dd
...@@ -464,9 +464,9 @@ retry: ...@@ -464,9 +464,9 @@ retry:
GetBitContext gb; GetBitContext gb;
if (init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size) >= 0 ) if (init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size) >= 0 )
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) { } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s); ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) { } else if (CONFIG_FLV_DECODER && s->h263_flv) {
......
...@@ -238,7 +238,7 @@ int ff_h263_resync(MpegEncContext *s){ ...@@ -238,7 +238,7 @@ int ff_h263_resync(MpegEncContext *s){
if(show_bits(&s->gb, 16)==0){ if(show_bits(&s->gb, 16)==0){
pos= get_bits_count(&s->gb); pos= get_bits_count(&s->gb);
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4) 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 else
ret= h263_decode_gob_header(s); ret= h263_decode_gob_header(s);
if(ret>=0) if(ret>=0)
...@@ -255,7 +255,7 @@ int ff_h263_resync(MpegEncContext *s){ ...@@ -255,7 +255,7 @@ int ff_h263_resync(MpegEncContext *s){
pos= get_bits_count(&s->gb); pos= get_bits_count(&s->gb);
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4) 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 else
ret= h263_decode_gob_header(s); ret= h263_decode_gob_header(s);
if(ret>=0) if(ret>=0)
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
typedef struct Mpeg4DecContext { typedef struct Mpeg4DecContext {
MpegEncContext m; MpegEncContext m;
int shape;
} Mpeg4DecContext; } Mpeg4DecContext;
/* dc encoding for mpeg4 */ /* dc encoding for mpeg4 */
...@@ -98,7 +100,7 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, ...@@ -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_set_mpeg4_time(MpegEncContext *s);
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number); 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_encode_video_packet_header(MpegEncContext *s);
void ff_mpeg4_clean_buffers(MpegEncContext *s); void ff_mpeg4_clean_buffers(MpegEncContext *s);
void ff_mpeg4_stuffing(PutBitContext *pbc); void ff_mpeg4_stuffing(PutBitContext *pbc);
...@@ -107,7 +109,7 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s); ...@@ -107,7 +109,7 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s);
void ff_clean_mpeg4_qscales(MpegEncContext *s); void ff_clean_mpeg4_qscales(MpegEncContext *s);
int ff_mpeg4_decode_partitions(MpegEncContext *s); int ff_mpeg4_decode_partitions(MpegEncContext *s);
int ff_mpeg4_get_video_packet_prefix_length(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); void ff_mpeg4_init_direct_mv(MpegEncContext *s);
void ff_mpeg4videodec_static_init(void); void ff_mpeg4videodec_static_init(void);
......
...@@ -88,11 +88,11 @@ static int av_mpeg4_decode_header(AVCodecParserContext *s1, ...@@ -88,11 +88,11 @@ static int av_mpeg4_decode_header(AVCodecParserContext *s1,
if (avctx->extradata_size && pc->first_picture) { if (avctx->extradata_size && pc->first_picture) {
init_get_bits(gb, avctx->extradata, avctx->extradata_size * 8); 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); 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 || if (s->width && (!avctx->width || !avctx->height ||
!avctx->coded_width || !avctx->coded_height)) { !avctx->coded_width || !avctx->coded_height)) {
ret = ff_set_dimensions(avctx, s->width, s->height); ret = ff_set_dimensions(avctx, s->width, s->height);
......
...@@ -387,8 +387,10 @@ static int decode_new_pred(MpegEncContext *s, GetBitContext *gb) { ...@@ -387,8 +387,10 @@ static int decode_new_pred(MpegEncContext *s, GetBitContext *gb) {
* Decode the next video packet. * Decode the next video packet.
* @return <0 if something went wrong * @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 mb_num_bits = av_log2(s->mb_num - 1) + 1;
int header_extension = 0, mb_num, len; int header_extension = 0, mb_num, len;
...@@ -405,7 +407,7 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s) ...@@ -405,7 +407,7 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
return -1; return -1;
} }
if (s->shape != RECT_SHAPE) { if (ctx->shape != RECT_SHAPE) {
header_extension = get_bits1(&s->gb); header_extension = get_bits1(&s->gb);
// FIXME more stuff here // FIXME more stuff here
} }
...@@ -420,13 +422,13 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s) ...@@ -420,13 +422,13 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
s->mb_x = mb_num % s->mb_width; s->mb_x = mb_num % s->mb_width;
s->mb_y = 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); int qscale = get_bits(&s->gb, s->quant_precision);
if (qscale) if (qscale)
s->chroma_qscale = s->qscale = qscale; s->chroma_qscale = s->qscale = qscale;
} }
if (s->shape == RECT_SHAPE) if (ctx->shape == RECT_SHAPE)
header_extension = get_bits1(&s->gb); header_extension = get_bits1(&s->gb);
if (header_extension) { if (header_extension) {
...@@ -442,7 +444,7 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s) ...@@ -442,7 +444,7 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
skip_bits(&s->gb, 2); /* vop coding type */ skip_bits(&s->gb, 2); /* vop coding type */
// FIXME not rect stuff here // 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 */ skip_bits(&s->gb, 3); /* intra dc vlc threshold */
// FIXME don't just ignore everything // FIXME don't just ignore everything
if (s->pict_type == AV_PICTURE_TYPE_S && if (s->pict_type == AV_PICTURE_TYPE_S &&
...@@ -1686,8 +1688,9 @@ static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb) ...@@ -1686,8 +1688,9 @@ static int mpeg4_decode_profile_level(MpegEncContext *s, GetBitContext *gb)
return 0; 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; int width, height, vo_ver_id;
/* vol header */ /* vol header */
...@@ -1733,10 +1736,10 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb) ...@@ -1733,10 +1736,10 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb)
s->low_delay = 0; s->low_delay = 0;
} }
s->shape = get_bits(gb, 2); /* vol shape */ ctx->shape = get_bits(gb, 2); /* vol shape */
if (s->shape != RECT_SHAPE) if (ctx->shape != RECT_SHAPE)
av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n"); 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"); av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4); /* video_object_layer_shape_extension */ skip_bits(gb, 4); /* video_object_layer_shape_extension */
} }
...@@ -1763,8 +1766,8 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb) ...@@ -1763,8 +1766,8 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb)
s->t_frame = 0; s->t_frame = 0;
if (s->shape != BIN_ONLY_SHAPE) { if (ctx->shape != BIN_ONLY_SHAPE) {
if (s->shape == RECT_SHAPE) { if (ctx->shape == RECT_SHAPE) {
check_marker(gb, "before width"); check_marker(gb, "before width");
width = get_bits(gb, 13); width = get_bits(gb, 13);
check_marker(gb, "before height"); check_marker(gb, "before height");
...@@ -2087,8 +2090,9 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb) ...@@ -2087,8 +2090,9 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb)
return 0; 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; int time_incr, time_increment;
int64_t pts; int64_t pts;
...@@ -2198,7 +2202,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2198,7 +2202,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
if (s->new_pred) if (s->new_pred)
decode_new_pred(s, gb); decode_new_pred(s, gb);
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_P ||
(s->pict_type == AV_PICTURE_TYPE_S && (s->pict_type == AV_PICTURE_TYPE_S &&
s->vol_sprite_usage == GMC_SPRITE))) { s->vol_sprite_usage == GMC_SPRITE))) {
...@@ -2209,7 +2213,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2209,7 +2213,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
} }
// FIXME reduced res stuff // 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) { if (s->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
skip_bits(gb, 13); /* width */ skip_bits(gb, 13); /* width */
skip_bits1(gb); /* marker */ skip_bits1(gb); /* marker */
...@@ -2227,7 +2231,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2227,7 +2231,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
// FIXME complexity estimation stuff // 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); skip_bits_long(gb, s->cplx_estimation_trash_i);
if (s->pict_type != AV_PICTURE_TYPE_I) if (s->pict_type != AV_PICTURE_TYPE_I)
skip_bits_long(gb, s->cplx_estimation_trash_p); skip_bits_long(gb, s->cplx_estimation_trash_p);
...@@ -2270,7 +2274,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2270,7 +2274,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n"); 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); s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision);
if (s->qscale == 0) { if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
...@@ -2319,7 +2323,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2319,7 +2323,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
} }
if (!s->scalability) { 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 skip_bits1(gb); // vop shape coding type
} else { } else {
if (s->enhancement_type) { if (s->enhancement_type) {
...@@ -2360,8 +2364,9 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2360,8 +2364,9 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
* FRAME_SKIPPED if a not coded VOP is found * FRAME_SKIPPED if a not coded VOP is found
* 0 if a 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; unsigned startcode, v;
/* search next start code */ /* search next start code */
...@@ -2451,7 +2456,7 @@ int ff_mpeg4_decode_picture_header(MpegEncContext *s, GetBitContext *gb) ...@@ -2451,7 +2456,7 @@ int ff_mpeg4_decode_picture_header(MpegEncContext *s, GetBitContext *gb)
} }
if (startcode >= 0x120 && startcode <= 0x12F) { if (startcode >= 0x120 && startcode <= 0x12F) {
if (decode_vol_header(s, gb) < 0) if (decode_vol_header(ctx, gb) < 0)
return -1; return -1;
} else if (startcode == USER_DATA_STARTCODE) { } else if (startcode == USER_DATA_STARTCODE) {
decode_user_data(s, gb); decode_user_data(s, gb);
...@@ -2472,7 +2477,7 @@ end: ...@@ -2472,7 +2477,7 @@ end:
s->low_delay = 1; s->low_delay = 1;
s->avctx->has_b_frames = !s->low_delay; s->avctx->has_b_frames = !s->low_delay;
return decode_vop_header(s, gb); return decode_vop_header(ctx, gb);
} }
av_cold void ff_mpeg4videodec_static_init(void) { av_cold void ff_mpeg4videodec_static_init(void) {
...@@ -2512,6 +2517,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, ...@@ -2512,6 +2517,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
if (ret < 0) if (ret < 0)
return ret; return ret;
s->shape = s1->shape;
return 0; return 0;
} }
......
...@@ -748,7 +748,8 @@ do {\ ...@@ -748,7 +748,8 @@ do {\
// MPEG4 timing info // MPEG4 timing info
memcpy(&s->time_increment_bits, &s1->time_increment_bits, 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 // B-frame info
s->max_b_frames = s1->max_b_frames; s->max_b_frames = s1->max_b_frames;
......
...@@ -594,7 +594,6 @@ typedef struct MpegEncContext { ...@@ -594,7 +594,6 @@ typedef struct MpegEncContext {
uint16_t pb_time; ///< time distance between the last b and p,s,i frame uint16_t pb_time; ///< time distance between the last b and p,s,i frame
uint16_t pp_field_time; uint16_t pp_field_time;
uint16_t pb_field_time; ///< like above, just for interlaced uint16_t pb_field_time; ///< like above, just for interlaced
int shape;
int vol_sprite_usage; int vol_sprite_usage;
int sprite_width; int sprite_width;
int sprite_height; int sprite_height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment