[FFmpeg-devel] [PATCH] flacenc: Support attaching pictures
Paul B Mahol
onemda at gmail.com
Tue Aug 6 23:59:06 CEST 2013
On 8/6/13, James Almer <jamrial at gmail.com> wrote:
> On 06/08/13 6:54 AM, Paul B Mahol wrote:
>> On 8/5/13, James Almer <jamrial at gmail.com> wrote:
>>> - avio_write(s->pb, pkt->data, pkt->size);
>>> + FLACContext *flac = s->priv_data;
>>> +
>>> + if (pkt->stream_index == flac->audio_stream_idx) {
>>> + if (flac->pics_to_write) {
>>> + /* buffer audio packets until we get all the pictures */
>>> + AVPacketList *pktl = av_mallocz(sizeof(*pktl));
>>> + if (!pktl)
>>> + return AVERROR(ENOMEM);
>>> +
>>> + pktl->pkt = *pkt;
>>> + pktl->pkt.buf = av_buffer_ref(pkt->buf);
>>> + if (!pktl->pkt.buf) {
>>> + av_freep(&pktl);
>>> + return AVERROR(ENOMEM);
>>> + }
>>
>> So this eats endless memory? How much of it is buffered?
>>
>> This is extremly sloppy/ugly/complicated/buggy design.
>
> This is a design taken from the MP3 muxer, so it was seen as a good solution
> at
> some point.
> It will buffer audio packets in memory until the last video/picture packet
> is
> received and processed (One per picture). At that point every buffered audio
>
> packet will be flushed to the aviocontext, and every new packet written
> directly.
Can this code be moved at separate file, instead of being duplicated
all the time.
So it can be easily replaced in future.
More information about the ffmpeg-devel
mailing list