[FFmpeg-devel] [PATCH] libavcodec/zmbv.c: Don't modify const buffer

Benoit Fouet benoit.fouet
Tue Feb 17 14:31:00 CET 2009

On 02/17/2009 02:12 PM, Patrik Kullman wrote:
> On Tue, 2009-02-17 at 14:09 +0100, Benoit Fouet wrote:
>> Hi,
>> On 02/17/2009 01:56 PM, Patrik Kullman wrote:
>>> Trying to solve this issue somewhere else than BSFs until that API is
>>> sorted out.
>>> Copy the const input buffer into the Zlib struct instead of using the
>>> same address.
>>> Prevents warning:
>>> libavcodec/zmbv.c: In function ?decode_frame?:
>>> libavcodec/zmbv.c:494: warning: assignment discards qualifiers from
>>> pointer target type
>>> After inflate() is complated, free next_in.
>> well, IMHO, the zlib z_stream structure is lacking a const qualifier, we
>> shouldn't copy the input stream just to work that around.
> Well, from the zlib.h:
> <snip>
>   The detailed semantics are as follows. inflate performs one or both of the
>   following actions:
>   - Decompress more input starting at next_in and update next_in and avail_in
>     accordingly. If not all input can be processed (because there is not
>     enough room in the output buffer), next_in is updated and processing
>     will resume at this point for the next call of inflate().
> </snip>
> If next_in is updated I guess it shouldn't be a const?

well... next_in is modified... what you've put in next_in is not.
the data to which next_in points is never written, but only read.

you can do the following:


#include <stdio.h>

struct foo {
    const char *bar;
static void func(struct foo *in)
int main(int argc, char *argv[])
    struct foo a = { .bar = argv[argc-1] };

    printf("%s\n", a.bar);
    printf("%s\n", a.bar);

    return 0;



More information about the ffmpeg-devel mailing list