mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-01-12 00:06:51 +08:00
avformat/demux: use a stream specific temporary packet for the parser
This will be useful for the next commit. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -59,6 +59,8 @@ void ff_free_stream(AVStream **pst)
|
||||
av_freep(&sti->index_entries);
|
||||
av_freep(&sti->probe_data.buf);
|
||||
|
||||
av_packet_free(&sti->parse_pkt);
|
||||
|
||||
av_bsf_free(&sti->extract_extradata.bsf);
|
||||
|
||||
if (sti->info) {
|
||||
|
||||
@@ -1175,9 +1175,9 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
|
||||
{
|
||||
FormatContextInternal *const fci = ff_fc_internal(s);
|
||||
FFFormatContext *const si = &fci->fc;
|
||||
AVPacket *out_pkt = si->parse_pkt;
|
||||
AVStream *st = s->streams[stream_index];
|
||||
FFStream *const sti = ffstream(st);
|
||||
AVPacket *out_pkt = sti->parse_pkt;
|
||||
const AVPacketSideData *sd = NULL;
|
||||
const uint8_t *data = pkt->data;
|
||||
uint8_t *extradata = sti->avctx->extradata;
|
||||
|
||||
@@ -314,6 +314,21 @@ typedef struct FFStream {
|
||||
enum AVStreamParseType need_parsing;
|
||||
struct AVCodecParserContext *parser;
|
||||
|
||||
/**
|
||||
* The generic code uses this as a temporary packet
|
||||
* to parse packets or for muxing, especially flushing.
|
||||
* For demuxers, it may also be used for other means
|
||||
* for short periods that are guaranteed not to overlap
|
||||
* with calls to av_read_frame() (or ff_read_packet())
|
||||
* or with each other.
|
||||
* It may be used by demuxers as a replacement for
|
||||
* stack packets (unless they call one of the aforementioned
|
||||
* functions with their own AVFormatContext).
|
||||
* Every user has to ensure that this packet is blank
|
||||
* after using it.
|
||||
*/
|
||||
AVPacket *parse_pkt;
|
||||
|
||||
/**
|
||||
* Number of frames that have been demuxed during avformat_find_stream_info()
|
||||
*/
|
||||
|
||||
@@ -270,6 +270,10 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
|
||||
|
||||
sti->fmtctx = s;
|
||||
|
||||
sti->parse_pkt = av_packet_alloc();
|
||||
if (!sti->parse_pkt)
|
||||
goto fail;
|
||||
|
||||
if (s->iformat) {
|
||||
sti->avctx = avcodec_alloc_context3(NULL);
|
||||
if (!sti->avctx)
|
||||
|
||||
Reference in New Issue
Block a user