[FFmpeg-devel] Google Summer of Code participation

Michael Niedermayer michaelni
Thu Apr 9 21:18:47 CEST 2009


On Thu, Apr 09, 2009 at 08:35:57PM +0200, Thilo Borgmann wrote:
>
>
> Michael Niedermayer schrieb:
>> On Thu, Apr 09, 2009 at 08:00:02PM +0200, Thilo Borgmann wrote:
>> [...]
>>   
>>> I've attached revision 2.
>>>     
>>
>> no you have not
>>
>>   
> Aah! But this time...
>
> TB

> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index fadbcd0..7b4bcea 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -37,7 +37,8 @@ typedef struct PNGDecContext {
>      const uint8_t *bytestream;
>      const uint8_t *bytestream_start;
>      const uint8_t *bytestream_end;
> -    AVFrame picture;
> +    AVFrame picture1, picture2;
> +    AVFrame *current_picture, *last_picture;
>  
>      int state;
>      int width, height;
> @@ -385,10 +386,14 @@ static int decode_frame(AVCodecContext *avctx,
>      int buf_size = avpkt->size;
>      PNGDecContext * const s = avctx->priv_data;
>      AVFrame *picture = data;
> -    AVFrame * const p= &s->picture;
> +    AVFrame *p;
>      uint32_t tag, length;
>      int ret, crc;
>  
> +    FFSWAP(AVFrame *, s->current_picture, s->last_picture);
> +    avctx->coded_frame= s->current_picture;
> +    p = s->current_picture;
> +
>      s->bytestream_start=
>      s->bytestream= buf;
>      s->bytestream_end= buf + buf_size;

> @@ -584,7 +589,24 @@ static int decode_frame(AVCodecContext *avctx,
>          }
>      }
>   exit_loop:
> -    *picture= s->picture;
> +     /* handle p-frames only if a predecessor frame is available */
> +     if(s->last_picture->data[0] != NULL) {
> +         if(!(avpkt->flags & PKT_FLAG_KEY)) {
> +            int i,j;
> +            int offset = 0;
> +            uint8_t *pd = s->current_picture->data[0];
> +            uint8_t *pd_last = s->last_picture->data[0];
> +
> +            for(j=0; j < s->height; j++) {
> +                for(i=0; i < s->width * s->bpp; i++) {
> +                    pd[offset + i] = pd[offset + i] + pd_last[offset + i];
> +                }
> +                offset += s->image_linesize;

pd += linesize
pd_last += linesize
-> no more offset needed


> +            }
> +        }
> +    }
> +
> +    *picture= *s->current_picture;
>      *data_size = sizeof(AVFrame);
>  
>      ret = s->bytestream - s->bytestream_start;
> @@ -602,8 +624,11 @@ static int decode_frame(AVCodecContext *avctx,
>  static av_cold int png_dec_init(AVCodecContext *avctx){
>      PNGDecContext *s = avctx->priv_data;
>  
> -    avcodec_get_frame_defaults(&s->picture);
> -    avctx->coded_frame= &s->picture;
> +    s->current_picture = &s->picture1;
> +    s->last_picture = &s->picture2;
> +    avcodec_get_frame_defaults(&s->picture1);
> +    avcodec_get_frame_defaults(&s->picture2);

> +    avctx->coded_frame= s->current_picture;

unneeded

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090409/907e0140/attachment.pgp>



More information about the ffmpeg-devel mailing list