mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Merge commit 'ee8af2dd99dcb7a01a667deedec81d1aa2a00d72'
* commit 'ee8af2dd99dcb7a01a667deedec81d1aa2a00d72': mpeg4videodec: move MpegEncContext.shape to Mpeg4DecContext Conflicts: libavcodec/h263dec.c libavcodec/mpeg4videodec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
ad13b8ca9b
@ -464,9 +464,9 @@ retry:
|
||||
GetBitContext gb;
|
||||
|
||||
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) {
|
||||
ret = ff_intel_h263_decode_picture_header(s);
|
||||
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
|
||||
|
@ -238,7 +238,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)
|
||||
@ -255,7 +255,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)
|
||||
|
@ -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);
|
||||
void ff_mpeg4videodec_static_init(void);
|
||||
|
||||
|
@ -88,11 +88,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);
|
||||
|
@ -387,8 +387,10 @@ static int decode_new_pred(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;
|
||||
|
||||
@ -405,7 +407,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
|
||||
}
|
||||
@ -420,13 +422,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) {
|
||||
@ -442,7 +444,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 &&
|
||||
@ -1686,8 +1688,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 */
|
||||
@ -1733,10 +1736,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 */
|
||||
}
|
||||
@ -1763,8 +1766,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) {
|
||||
check_marker(gb, "before width");
|
||||
width = get_bits(gb, 13);
|
||||
check_marker(gb, "before height");
|
||||
@ -2087,8 +2090,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;
|
||||
int64_t pts;
|
||||
|
||||
@ -2198,7 +2202,7 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb)
|
||||
if (s->new_pred)
|
||||
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_S &&
|
||||
s->vol_sprite_usage == GMC_SPRITE))) {
|
||||
@ -2209,7 +2213,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 */
|
||||
@ -2227,7 +2231,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);
|
||||
@ -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");
|
||||
}
|
||||
|
||||
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,
|
||||
@ -2319,7 +2323,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) {
|
||||
@ -2360,8 +2364,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 */
|
||||
@ -2451,7 +2456,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);
|
||||
@ -2472,7 +2477,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);
|
||||
}
|
||||
|
||||
av_cold void ff_mpeg4videodec_static_init(void) {
|
||||
@ -2512,6 +2517,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
s->shape = s1->shape;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,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;
|
||||
|
@ -594,7 +594,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;
|
||||
|
Loading…
Reference in New Issue
Block a user