-//FIXME reduced res stuff
-
- if (s->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 */
- skip_bits(gb, 13); /* height */
- skip_bits1(gb); /* marker */
- skip_bits(gb, 13); /* hor_spat_ref */
- skip_bits1(gb); /* marker */
- skip_bits(gb, 13); /* ver_spat_ref */
- }
- skip_bits1(gb); /* change_CR_disable */
-
- if (get_bits1(gb) != 0) {
- skip_bits(gb, 8); /* constant_alpha_value */
- }
- }
-//FIXME complexity estimation stuff
-
- if (s->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);
- if(s->pict_type == AV_PICTURE_TYPE_B)
- skip_bits_long(gb, s->cplx_estimation_trash_b);
-
- s->intra_dc_threshold= ff_mpeg4_dc_threshold[ get_bits(gb, 3) ];
- if(!s->progressive_sequence){
- s->top_field_first= get_bits1(gb);
- s->alternate_scan= get_bits1(gb);
- }else
- s->alternate_scan= 0;
- }
-
- if(s->alternate_scan){
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
- } else{
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
- }
-
- if(s->pict_type == AV_PICTURE_TYPE_S && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
- mpeg4_decode_sprite_trajectory(s, gb);
- if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
- if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
- }
-
- if (s->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, "Error, header damaged or not MPEG4 header (qscale=0)\n");
- return -1; // makes no sense to continue, as there is nothing left from the image then
- }
-
- if (s->pict_type != AV_PICTURE_TYPE_I) {
- s->f_code = get_bits(gb, 3); /* fcode_for */
- if(s->f_code==0){
- av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (f_code=0)\n");
- return -1; // makes no sense to continue, as the MV decoding will break very quickly
- }
- }else
- s->f_code=1;
-
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- s->b_code = get_bits(gb, 3);
- }else
- s->b_code=1;
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d\n",
- s->qscale, s->f_code, s->b_code,
- s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
- gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first,
- s->quarter_sample ? "q" : "h", s->data_partitioning, s->resync_marker, s->num_sprite_warping_points,
- s->sprite_warping_accuracy, 1-s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold, s->cplx_estimation_trash_i, s->cplx_estimation_trash_p, s->cplx_estimation_trash_b);
- }
-
- if(!s->scalability){
- if (s->shape!=RECT_SHAPE && s->pict_type!=AV_PICTURE_TYPE_I) {
- skip_bits1(gb); // vop shape coding type
- }
- }else{
- if(s->enhancement_type){
- int load_backward_shape= get_bits1(gb);
- if(load_backward_shape){
- av_log(s->avctx, AV_LOG_ERROR, "load backward shape isn't supported\n");
- }
- }
- skip_bits(gb, 2); //ref_select_code
- }
- }
- /* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/
- // note we cannot detect divx5 without b-frames easily (although it's buggy too)
- if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==-1 && s->picture_number==0){
- av_log(s->avctx, AV_LOG_WARNING, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
- s->low_delay=1;
- }
-
- s->picture_number++; // better than pic number==0 always ;)
-
- s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
- s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
-
- if(s->workaround_bugs&FF_BUG_EDGE){
- s->h_edge_pos= s->width;
- s->v_edge_pos= s->height;
- }
- return 0;
+ // FIXME reduced res stuff
+
+ if (ctx->shape != RECT_SHAPE) {
+ if (ctx->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
+ skip_bits(gb, 13); /* width */
+ skip_bits1(gb); /* marker */
+ skip_bits(gb, 13); /* height */
+ skip_bits1(gb); /* marker */
+ skip_bits(gb, 13); /* hor_spat_ref */
+ skip_bits1(gb); /* marker */
+ skip_bits(gb, 13); /* ver_spat_ref */
+ }
+ skip_bits1(gb); /* change_CR_disable */
+
+ if (get_bits1(gb) != 0)
+ skip_bits(gb, 8); /* constant_alpha_value */
+ }
+
+ // FIXME complexity estimation stuff
+
+ if (ctx->shape != BIN_ONLY_SHAPE) {
+ skip_bits_long(gb, ctx->cplx_estimation_trash_i);
+ if (s->pict_type != AV_PICTURE_TYPE_I)
+ skip_bits_long(gb, ctx->cplx_estimation_trash_p);
+ if (s->pict_type == AV_PICTURE_TYPE_B)
+ skip_bits_long(gb, ctx->cplx_estimation_trash_b);
+
+ ctx->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)];
+ if (!s->progressive_sequence) {
+ s->top_field_first = get_bits1(gb);
+ s->alternate_scan = get_bits1(gb);
+ } else
+ s->alternate_scan = 0;
+ }
+
+ if (s->alternate_scan) {
+ ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ } else {
+ ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);
+ ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
+ ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
+ ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ }
+
+ if (s->pict_type == AV_PICTURE_TYPE_S &&
+ (ctx->vol_sprite_usage == STATIC_SPRITE ||
+ ctx->vol_sprite_usage == GMC_SPRITE)) {
+ if (mpeg4_decode_sprite_trajectory(ctx, gb) < 0)
+ return AVERROR_INVALIDDATA;
+ if (ctx->sprite_brightness_change)
+ av_log(s->avctx, AV_LOG_ERROR,
+ "sprite_brightness_change not supported\n");
+ if (ctx->vol_sprite_usage == STATIC_SPRITE)
+ av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
+ }
+
+ 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,
+ "Error, header damaged or not MPEG-4 header (qscale=0)\n");
+ return -1; // makes no sense to continue, as there is nothing left from the image then
+ }
+
+ if (s->pict_type != AV_PICTURE_TYPE_I) {
+ s->f_code = get_bits(gb, 3); /* fcode_for */
+ if (s->f_code == 0) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Error, header damaged or not MPEG-4 header (f_code=0)\n");
+ return -1; // makes no sense to continue, as there is nothing left from the image then
+ }
+ } else
+ s->f_code = 1;
+
+ if (s->pict_type == AV_PICTURE_TYPE_B) {
+ s->b_code = get_bits(gb, 3);
+ } else
+ s->b_code = 1;
+
+ if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d\n",
+ s->qscale, s->f_code, s->b_code,
+ s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
+ gb->size_in_bits, s->progressive_sequence, s->alternate_scan,
+ s->top_field_first, s->quarter_sample ? "q" : "h",
+ s->data_partitioning, ctx->resync_marker,
+ ctx->num_sprite_warping_points, s->sprite_warping_accuracy,
+ 1 - s->no_rounding, s->vo_type,
+ ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold,
+ ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p,
+ ctx->cplx_estimation_trash_b);
+ }
+
+ if (!ctx->scalability) {
+ if (ctx->shape != RECT_SHAPE && s->pict_type != AV_PICTURE_TYPE_I)
+ skip_bits1(gb); // vop shape coding type
+ } else {
+ if (ctx->enhancement_type) {
+ int load_backward_shape = get_bits1(gb);
+ if (load_backward_shape)
+ av_log(s->avctx, AV_LOG_ERROR,
+ "load backward shape isn't supported\n");
+ }
+ skip_bits(gb, 2); // ref_select_code
+ }
+ }
+ /* detect buggy encoders which don't set the low_delay flag
+ * (divx4/xvid/opendivx). Note we cannot detect divx5 without B-frames
+ * easily (although it's buggy too) */
+ if (s->vo_type == 0 && ctx->vol_control_parameters == 0 &&
+ ctx->divx_version == -1 && s->picture_number == 0) {
+ av_log(s->avctx, AV_LOG_WARNING,
+ "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
+ s->low_delay = 1;
+ }
+
+ s->picture_number++; // better than pic number==0 always ;)
+
+ // FIXME add short header support
+ s->y_dc_scale_table = ff_mpeg4_y_dc_scale_table;
+ s->c_dc_scale_table = ff_mpeg4_c_dc_scale_table;
+
+ if (s->workaround_bugs & FF_BUG_EDGE) {
+ s->h_edge_pos = s->width;
+ s->v_edge_pos = s->height;
+ }
+ return 0;