Michael Riepe wrote:
...
> That breaks the build with local ffmpeg.
I didn't try that, my oops.

...
> Not actually necessary.
Agreed, they are only warnings. When compiling, it seems to me to be 
cleaner to not have warnings being output - and people wondering whether 
it is something going wrong. IMHO, in terms of portability it forces the 
compiler to do the evaluation correctly even if a particular compiler's 
operator precedence differed from the compiler that is currently used.

eg: a compiler that interprets:
buf[5] = (mm<<4) & 0xf0 | (ss>>3) & 0x07 | 0x08;
as:
buf[5] = (mm<<4) & (0xf0 | (ss>>3)) & (0x07 | 0x08);
I have no idea if such a thing exists ;)

>> Index: src/lavfmuxer.cpp
>> ===================================================================
>> --- src/lavfmuxer.cpp        (revision 116)
>> +++ src/lavfmuxer.cpp        (working copy)
>> @@ -89,7 +89,7 @@
>>          int16_t samples[6*1536]; // must be enough for 6 AC-3 channels --mr
>>          int frame_size=sizeof(samples);
>>          //fprintf(stderr, "** decode audio size=%d\n", sd->inbytes());
>> -        avcodec_decode_audio(s->codec,samples,&frame_size,
>> +        avcodec_decode_audio2(s->codec,samples,&frame_size,
>>                               (uint8_t*) sd->getdata(),sd->inbytes());
>>          avcodec_close(s->codec);
>>        }
> 
> avcodec_decode_audio2 doesn't exist in the local version of ffmpeg.
> 
> What's the difference, by the way?
In current ffmpeg {ffmpeg-0.4.9-0.44.20080113.lvn9}, various functions 
have been deprecated {both avcodec_decode_audio and img_copy}.

I notice that it was 2005 {according to the source} when ffmpeg was 
taken internally. How much work would it be to rebase the internal one 
to current ffmpeg svn ?

I might be putting my hand up to do it - based on the customizations the 
internal ffmpeg has to reduce it's size.

Or would you prefer to wait until ffmpeg actually removes that function 
{they don't seem to give a timeframe} ?

Even then it wouldn't strictly be necessary due to the internally 
included version, but would make it difficult for external packagers to 
build using system ffmpeg. {Also, a 500k dvbcut {plus libs} v a 2500k 
dvbcut, and any ffmpeg security/ crash issues applied more easily}.

For decode audio the function prototypes are the same:
==== from current avcodec.h:
/**
  * @deprecated Use avcodec_decode_audio2() instead.
  */
attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, 
int16_t *samples,
                          int *frame_size_ptr,
                          uint8_t *buf, int buf_size);

/**
  * Decodes an audio frame from \p buf into \p samples.
  * The avcodec_decode_audio2() function decodes an audio frame from the 
input
  * buffer \p buf of size \p buf_size. To decode it, it makes use of the
  * audio codec which was coupled with \p avctx using avcodec_open(). The
  * resulting decoded frame is stored in output buffer \p samples.  If 
no frame
  * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the
  * decompressed frame size in \e bytes.
  *
  * @warning You \e must set \p frame_size_ptr to the allocated size of the
  * output buffer before calling avcodec_decode_audio2().
  *
  * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE 
larger than
  * the actual read bytes because some optimized bitstream readers read 
32 or 64
  * bits at once and could read over the end.
  *
  * @warning The end of the input buffer \p buf should be set to 0 to 
ensure that
  * no overreading happens for damaged MPEG streams.
  *
  * @note You might have to align the input buffer \p buf and output 
buffer \p
  * samples. The alignment requirements depend on the CPU: On some CPUs 
it isn't
  * necessary at all, on others it won't work at all if not aligned and 
on others
  * it will work but it will have an impact on performance. In practice, the
  * bitstream should have 4 byte alignment at minimum and all sample 
data should
  * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE 
do). If
  * the linesize is not a multiple of 16 then there's no sense in 
aligning the
  * start of the buffer to 16.
  *
  * @param avctx the codec context
  * @param[out] samples the output buffer
  * @param[in,out] frame_size_ptr the output buffer size in bytes
  * @param[in] buf the input buffer
  * @param[in] buf_size the input buffer size in bytes
  * @return On error a negative value is returned, otherwise the number 
of bytes
  * used or zero if no frame could be decompressed.
  */
int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
                          int *frame_size_ptr,
                          uint8_t *buf, int buf_size);
====
 From included avcodec.h:
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
                          int *frame_size_ptr,
                          uint8_t *buf, int buf_size);
=====
The actual code is in avcodec/utils.c: {for current ffmpeg}
int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, 
int16_t *samples,
                          int *frame_size_ptr,
                          uint8_t *buf, int buf_size)
{
     int ret;

     if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
         //FIXME remove the check below _after_ ensuring that all audio 
check that the available space is enough
         if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
             av_log(avctx, AV_LOG_ERROR, "buffer smaller than 
AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
             return -1;
         }
         if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
         *frame_size_ptr < avctx->channels * avctx->frame_size * 
sizeof(int16_t)){
             av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", 
*frame_size_ptr);
             return -1;
         }

         ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
                                 buf, buf_size);
         avctx->frame_number++;
     }else{
         ret= 0;
         *frame_size_ptr=0;
     }
     return ret;
}

#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
                          int *frame_size_ptr,
                          uint8_t *buf, int buf_size){
     *frame_size_ptr= AVCODEC_MAX_AUDIO_FRAME_SIZE;
     return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, 
buf_size);
}
#endif

=====
The older code is in avcodec/utils.c: {for included ffmpeg}

/* decode an audio frame. return -1 if error, otherwise return the
    *number of bytes used. If no frame could be decompressed,
    *frame_size_ptr is zero. Otherwise, it is the decompressed frame
    *size in BYTES. */
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
                          int *frame_size_ptr,
                          uint8_t *buf, int buf_size)
{
     int ret;

     *frame_size_ptr= 0;
     if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
         ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
                                 buf, buf_size);
         avctx->frame_number++;
     }else
         ret= 0;
     return ret;
}
=====
So there appears to be some extra checking to make sure that things 
don't go wrong. Since the _2 version isn't in the included ffmpeg, then 
we couldn't directly apply without moving to a newer ffmpeg.

...
> Not necessary either.
Agreed. Not worth making a release for, but perhaps when the next 
serious patches come along.


+#include <cstring>
> I suppose this is for memcpy?
Yes. This is the one that actually allows it to compile.

Thanks for your time in perusing these patches.

DaveT.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to