[FFmpeg-devel] Google Summer of Code participation

Michael Niedermayer michaelni
Thu Apr 9 02:31:26 CEST 2009


On Thu, Apr 09, 2009 at 01:18:21AM +0200, Thilo Borgmann wrote:
> Ok, here it is, my first attempt for the CorePNG p-frame support. :)
> I've tested it with the corepng.avi test file and it works as expected.
>
> The for loop to add both buffers is most likely a case for optimization, 
> but as I'm not used to getting the last out of C I need help for that.
>
> Of course (as almost every patch has shown...) there will be other issues, 
> but please be merciful, it is my own patch realy providing new code.
>
> TB

> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index fadbcd0..f120743 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -51,6 +51,7 @@ typedef struct PNGDecContext {
>      int bpp;
>  
>      uint8_t *image_buf;
> +    uint8_t *last_image_buf;
>      int image_linesize;
>      uint32_t palette[256];
>      uint8_t *crow_buf;
> @@ -584,6 +585,33 @@ static int decode_frame(AVCodecContext *avctx,
>          }
>      }
>   exit_loop:
> +     /* handle p-frames only if a predecessor frame is available */
> +     if(s->last_image_buf != NULL) {
> +         if(!(avpkt->flags & PKT_FLAG_KEY)) {

> +            int i = 0;
> +            int j = 0;

redudnant init

> +            int offset = 0;
> +            uint8_t *pd = s->image_buf;
> +            uint8_t *pd_last = s->last_image_buf;
> +
> +            for(j=0; j < s->height; j++) {

> +                for(i=0; i < s->image_linesize; i++) {

width


> +                    pd[offset + i] = pd[offset + i] + pd_last[offset + i];
> +                }
> +                offset += (s->picture).linesize[0];
> +            }
> +        }
> +    }
> +    else {
> +        /* allocate a buffer to store the last frame if not yet done */
> +        s->last_image_buf = av_malloc(s->image_linesize * s->height);
> +        if(s->last_image_buf == NULL) av_log(avctx, AV_LOG_ERROR, "av_malloc() failed\n");
> +    }
> +
> +    /* preserve the last decoded frame for p-frame decoding */
> +    if(s->last_image_buf != NULL) 

trailing whitespace


> +        memcpy(s->last_image_buf, s->image_buf, s->image_linesize * s->height);

memcpy should not be needed for decoding

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- 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/b1ef6827/attachment.pgp>



More information about the ffmpeg-devel mailing list