[FFmpeg-devel] Google Summer of Code participation

Michael Niedermayer michaelni
Thu Apr 9 16:28:54 CEST 2009


On Thu, Apr 09, 2009 at 09:19:00AM +0200, Thilo Borgmann wrote:
>
>
> Michael Niedermayer schrieb:
>>>>> +            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
>>>>
>>>>         
>>> No. image_linesize != width. Linesize is needed here as the copy is done 
>>> byte-wise. But there are s->height of these long lines.
>>>     
>>
>> we want to just change width pixels not linesize samples.
>>
>>
>>   
> From that point of view, yes of course. But as we have a uint8_t pointer, 
> which increments by 8-bit and a picture buffer with 24 bits per pixel in 
> that case...
> I've used width in revision 1 but this is worse as there are 12 new 
> multiplications per iteration instead of 3 times as many iterations.
> And this way even works only with 3 bytes a pixel, what about 8 and 16 or 
> 32?
> The linesize version is independent...
> What do I not understand?
>>>
>>> Hmm to avoid this call I think about double buffering via a second 
>>> AVFrame in the PNGContext instead of a uint8_t buffer? If you agree I 
>>> will do this tomorrow.
>>>     
>>
>> yes, that was my thought as well
>>
>>   
> Done.
>
> Revision 1 attached, just for reviewing the double buffering... there is 
> still the width<->linesize issue...
>
> TB

> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index fadbcd0..3ea75a7 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;

> @@ -377,6 +378,13 @@ static int png_decode_idat(PNGDecContext *s, int length)
>      return 0;
>  }
>  
> +static void png_flip_pictures(PNGDecContext *s)
> +{
> +    AVFrame *dummy = s->current_picture;
> +    s->current_picture = s->last_picture;
> +    s->last_picture = dummy;
> +}
> +

FFSWAP


[...]

> +                for(i=0; i < s->width; i++) {
> +                    pd[offset + 0 + i*3] = pd[offset + 0 + i*3] + pd_last[offset + 0 + i*3];
> +                    pd[offset + 1 + i*3] = pd[offset + 1 + i*3] + pd_last[offset + 1 + i*3];
> +                    pd[offset + 2 + i*3] = pd[offset + 2 + i*3] + pd_last[offset + 2 + i*3];
> +                }

for(j=0; j<width*3; j++)

[...]
> @@ -602,8 +632,10 @@ 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);

> +    avctx->coded_frame= &s->picture1;

this is wrong

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- 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/c6a1c64d/attachment.pgp>



More information about the ffmpeg-devel mailing list