[FFmpeg-devel] Re-open bug 852?

dave.jenkins at att.net dave.jenkins
Mon Aug 3 04:23:17 CEST 2009


Folks,

I'm having ffmpeg segfault whenever it calls function
resample2.c: av_resample_compensate.  I'm no C guru, but it
seems to me that we are trying (in ffmepg.c line 656)
to cast a ReSampleContext into a AVResampleContext.  ReSampleContext
does contain a AVResampleContext, and it is the first thing in
the structure, so perhaps that is how this works for some people.
But for me using gcc 4.1.2 and gcc 4.3.2 at least it isn't working. 

A solution would be to pass in ost->resample->resample_context,
but we can't do that because the details of ReSampleContext are
not known in ffmpeg.c.

I propose changing avcodec.h:

1. change the prototype for av_resample_compensate to take
a ReSampleContext as the first argument.
2. add a AVResampleContext * get_av_resample_context(ReSampleContext *)
call that can get teh AVResampleContxt from a given ReSampleContext.

----- ./libavcodec/avcodec.h -----
2866c2866,2867
< void av_resample_compensate(struct AVResampleContext *c, int
sample_delta, int compensation_distance);
---
> struct AVResampleContext * get_av_resample_context(ReSampleContext * c);
> void av_resample_compensate(ReSampleContext *c, int sample_delta, int
> compensation_distance);

Changing resample2.c to implemnt the change in prototype to
av_reample_compensate and then call teh get_av_resample_context
to get the ReSampleContext to return its AVReampleContext.

----- ./libavcodec/resample2.c -----
206c206,207
< void av_resample_compensate(AVResampleContext *c, int sample_delta,
int compensation_distance){
---
> void av_resample_compensate(ReSampleContext *rc, int sample_delta, int
> compensation_distance){
>       AVResampleContext * c = get_av_resmple_context(rc);

Change resample.c to implement the get_av_resample_context.

----- ./libavcodec/resample.c -----
54a55,57
> struct AVResampleContext * get_av_resample_context(ReSampleContext * c) {
>       return c->resample_context;
> }

Finally, change ffmpeg to pass in the ReSampleContext instead
of the cast of it.

----- ./ffmpeg.c -----
656c656
<                 av_resample_compensate(*(struct
AVResampleContext**)ost->resample, comp, enc->sample_rate);
---
>                 av_resample_compensate(ost->resample, comp,
>                 enc->sample_rate);
     
This seems to work for me.

-- 

Dave Jenkins - dave.jenkins at att.net




More information about the ffmpeg-devel mailing list