On 11/30/2011 02:56 PM, Anton Khirnov wrote:

> 
> On Sat, 26 Nov 2011 17:07:07 -0500, Justin Ruggles <[email protected]> 
> wrote:
>> ---
>>  avplay.c |   41 +++++++++++++++++++++++++----------------
>>  1 files changed, 25 insertions(+), 16 deletions(-)
>>
>> diff --git a/avplay.c b/avplay.c
>> index 1005cba..c90b7f8 100644
>> --- a/avplay.c
>> +++ b/avplay.c
>> @@ -153,12 +153,9 @@ typedef struct VideoState {
>>      AVStream *audio_st;
>>      PacketQueue audioq;
>>      int audio_hw_buf_size;
>> -    /* samples output by the codec. we reserve more space for avsync
>> -       compensation */
>> -    DECLARE_ALIGNED(16,uint8_t,audio_buf1)[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 
>> 3) / 2];
>> -    DECLARE_ALIGNED(16,uint8_t,audio_buf2)[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 
>> 3) / 2];
>>      uint8_t silence_buf[SDL_AUDIO_BUFFER_SIZE];
>>      uint8_t *audio_buf;
>> +    uint8_t *audio_buf1;
>>      unsigned int audio_buf_size; /* in bytes */
>>      int audio_buf_index; /* in bytes */
>>      AVPacket audio_pkt_temp;
>> @@ -2010,21 +2007,21 @@ static int audio_decode_frame(VideoState *is, double 
>> *pts_ptr)
>>      AVPacket *pkt_temp = &is->audio_pkt_temp;
>>      AVPacket *pkt = &is->audio_pkt;
>>      AVCodecContext *dec= is->audio_st->codec;
>> -    int n, len1, data_size;
>> +    int n, len1, data_size, got_frame;
>>      double pts;
>>      int new_packet = 0;
>>      int flush_complete = 0;
>> +    AVFrame *decoded_frame = NULL;
>>  
>>      for(;;) {
>>          /* NOTE: the audio packet can contain several frames */
>>          while (pkt_temp->size > 0 || (!pkt_temp->data && new_packet)) {
>> +            if (!(decoded_frame = avcodec_alloc_frame()))
>> +                return AVERROR(ENOMEM);
> 
> Wouldn't it be better to allocate the frame only once and then just
> reset it with avcodec_get_frame_defaults()?


yeah, true.

i'm wondering if frame defaults even need to be set. nothing from the
source frame is preserved.

-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to