On Wed, 25 Jan 2012, Ronald S. Bultje wrote:
Hi,On Sat, Jan 21, 2012 at 2:02 AM, Martin Storsjö <[email protected]> wrote:@@ -2370,13 +2371,19 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; + MOVTrack *trk = &mov->tracks[pkt ? pkt->stream_index : 0]; AVCodecContext *enc = trk->enc; unsigned int samplesInChunk = 0; - int size= pkt->size; + int size = pkt ? pkt->size : 0; uint8_t *reformatted_data = NULL; if (!s->pb->seekable) return 0; /* Can't handle that */ + + if (!pkt) { + mov_flush_fragment(s); + return 0; + }This is kinda ugly, I'd prefer a new function called write_pkt_internal() which is the above ff_mov_...(), and then a new function for that like this: void ff_mov_write_packet(..) { if (pkt) { write_pkt_internal(..); } else { mov_flush_fragment(..); } } Then the other ifs become unnecessary.
Good point, rewrote it in this form. // Martin
_______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
