[FFmpeg-devel] [PATCH 1/4] Support reference picture defined by bitmask in MJPEG's SOS decoder

Michael Niedermayer michaelni at gmx.at
Thu Mar 31 02:31:11 CEST 2011


On Mon, Mar 28, 2011 at 12:01:40AM +0400, Anatoly Nenashev wrote:
[...]
> @@ -851,29 +884,43 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i
>      return 0;
>  }
>  
> -static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int se, int Ah, int Al){
> +static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int se, int Ah, int Al,
> +                                            const uint8_t *mb_bitmask, const AVFrame *reference){
>      int mb_x, mb_y;
>      int EOBRUN = 0;
>      int c = s->comp_index[0];
>      uint8_t* data = s->picture.data[c];
> +    const uint8_t *reference_data = reference ? reference->data[c] : NULL;
>      int linesize = s->linesize[c];
>      int last_scan = 0;
>      int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
> +    GetBitContext mb_bitmask_gb;
> +
> +    if (mb_bitmask) {
> +        init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
> +    }
>  
>      if(!Al) {
>          s->coefs_finished[c] |= (1LL<<(se+1))-(1LL<<ss);
>          last_scan = !~s->coefs_finished[c];
>      }
>  
> -    if(s->interlaced && s->bottom_field)
> -        data += linesize >> 1;
> +    if(s->interlaced && s->bottom_field) {
> +        int offset = linesize >> 1;
> +        data += offset;
> +        reference_data += offset;
> +    }
>  
>      for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
> -        uint8_t *ptr = data + (mb_y*linesize*8 >> s->avctx->lowres);
> +        int block_offset = (mb_y*linesize*8 >> s->avctx->lowres);
> +        uint8_t *ptr = data + block_offset;
>          int block_idx = mb_y * s->block_stride[c];
>          DCTELEM (*block)[64] = &s->blocks[c][block_idx];
>          uint8_t *last_nnz = &s->last_nnz[c][block_idx];
>          for(mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) {
> +            const int copy_mb = mb_bitmask && !get_bits1(&mb_bitmask_gb);
> +
> +            if (!copy_mb) {
>              int ret;
>              if(Ah)
>                  ret = decode_block_refinement(s, *block, last_nnz, s->ac_index[0],
> @@ -885,16 +932,23 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int s
>                  av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x);
>                  return -1;
>              }
> +            }
> +
>              if(last_scan) {
> +                if (copy_mb) {
> +                    mjpeg_copy_block(ptr, reference_data + block_offset, linesize, s->avctx->lowres);
> +                } else {
>                  s->dsp.idct_put(ptr, linesize, *block);
>                  ptr += 8 >> s->avctx->lowres;
> +                }
>              }
>          }
>      }
>      return 0;
>  }
>  
> -int ff_mjpeg_decode_sos(MJpegDecodeContext *s)
> +int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
> +                        const uint8_t *mb_bitmask, const AVFrame *reference)
>  {
>      int len, nb_components, i, h, v, predictor, point_transform;
>      int index, id;
> @@ -996,10 +1050,12 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s)
>          }
>      }else{
>          if(s->progressive && predictor) {
> -            if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
> +            if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform,
> +                                                mb_bitmask, reference) < 0)
>                  return -1;
>          } else {
> -            if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform) < 0)
> +            if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform,
> +                                 mb_bitmask, reference) < 0)
>                  return -1;
>          }
>      }

does progressive mxpeg samples exist?
if not the related changes are unneeded and unneccesarily increase
code complexity and decrease speed

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110331/3dc7e656/attachment.asc>


More information about the ffmpeg-devel mailing list