Created
July 22, 2012 06:47
-
-
Save j0sh/3158723 to your computer and use it in GitHub Desktop.
libavformat: Add option to queue packets during stream analysis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commit cdc0833efaa19b695bea16b69a49d2e9adb90d0e | |
| Author: Josh Allmann <joshua.allmann@gmail.com> | |
| Date: Sat Jul 21 23:32:16 2012 -0700 | |
| libavformat: Add option to queue packets during stream analysis. | |
| Useful in cases where a significant analyzeduration is | |
| still needed, while minimizing buffering before output. | |
| Useful for eg, processing low-latency streams where all | |
| media types won't necessarily come in if the analysis | |
| phase is brief. | |
| diff --git a/libavformat/avformat.h b/libavformat/avformat.h | |
| index e292206..bd323dc 100644 | |
| --- a/libavformat/avformat.h | |
| +++ b/libavformat/avformat.h | |
| @@ -985,6 +985,11 @@ typedef struct AVFormatContext { | |
| * Flags to enable debugging. | |
| */ | |
| int debug; | |
| + | |
| + /** | |
| + * Flag to to queue packets read during stream analysis | |
| + */ | |
| + int queue_analysis; | |
| #define FF_FDEBUG_TS 0x0001 | |
| /***************************************************************** | |
| * All fields below this line are not part of the public API. They | |
| diff --git a/libavformat/options_table.h b/libavformat/options_table.h | |
| index 58f3dcf..9790e6b 100644 | |
| --- a/libavformat/options_table.h | |
| +++ b/libavformat/options_table.h | |
| @@ -41,6 +41,7 @@ static const AVOption options[]={ | |
| {"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"}, | |
| {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, | |
| {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D}, | |
| +{"queueanalysis", "queue packets read during stream analysis", OFFSET(queue_analysis), AV_OPT_TYPE_INT, {.dbl = 1}, 0, INT_MAX, E|D}, | |
| {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, | |
| {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D}, | |
| {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ | |
| diff --git a/libavformat/utils.c b/libavformat/utils.c | |
| index 156c527..99fbb2f 100644 | |
| --- a/libavformat/utils.c | |
| +++ b/libavformat/utils.c | |
| @@ -2382,9 +2382,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) | |
| break; | |
| } | |
| + if (ic->queue_analysis) { | |
| pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end); | |
| if ((ret = av_dup_packet(pkt)) < 0) | |
| goto find_stream_info_err; | |
| + } else | |
| + pkt = &pkt1; | |
| read_size += pkt->size; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment