History

avformat: add av_format_inject_global_side_data(), and disable it by default

After this commit applications needs to call av_format_inject_global_side_data() or handle AVStream side data by some other means if they want it not to be lost. This fixes a API incompatibility with libav. libav API does not allow the data to be passed through AVPackets

Michael Niedermayer committed 12 years ago

Commit ef818d81 parent 2adcd155 files · +32 −4Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. ffplay.c +2 −0
  3. libavformat/avformat.h +9 −1
  4. libavformat/internal.h +2 −0
  5. libavformat/utils.c +16 −3
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2014-04-XX - xxxxxxx - lavf xx.xx.1xx - avformat.h
19+ Add av_format_inject_global_side_data()
20+
1821 2014-04-12 - xxxxxxx - lavu 52.76.100 - log.h
1922 Add av_log_get_flags()
2023
ffplay.c+2−0
@@ -2752,6 +2752,8 @@ static int read_thread(void *arg) · 2751 unmodified lines
27522752 if (genpts)
27532753 ic->flags |= AVFMT_FLAG_GENPTS;
27542754
2755+ av_format_inject_global_side_data(ic);
2756+
27552757 opts = setup_find_stream_info_opts(ic, codec_opts);
27562758 orig_nb_streams = ic->nb_streams;
27572759
libavformat/avformat.h+9−1
@@ -862,6 +862,8 @@ typedef struct AVStream { · 861 unmodified lines
862862 * - muxing: May be set by the caller before avformat_write_header().
863863 *
864864 * Freed by libavformat in avformat_free_context().
865+ *
866+ * @see av_format_inject_global_side_data()
865867 */
866868 AVPacketSideData *side_data;
867869 /**
@@ -1043,7 +1045,7 @@ typedef struct AVStream { · 175 unmodified lines
10431045 /**
10441046 * Internal data to inject global side data
10451047 */
1046− int global_side_data_injected;
1048+ int inject_global_side_data;
10471049
10481050 } AVStream;
10491051
@@ -1612,6 +1614,12 @@ void av_format_set_opaque(AVFormatContext *s, void *opaque); · 562 unmodified lines
16121614 av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s);
16131615 void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback);
16141616
1617+/**
1618+ * This function will cause global side data to be injected in the next packet
1619+ * of each stream as well as after any subsequent seek.
1620+ */
1621+void av_format_inject_global_side_data(AVFormatContext *s);
1622+
16151623 /**
16161624 * Returns the method used to set ctx->duration.
16171625 *
libavformat/internal.h+2−0
@@ -52,6 +52,8 @@ struct AVFormatInternal { · 51 unmodified lines
5252 * Muxing only.
5353 */
5454 int nb_interleaved_streams;
55+
56+ int inject_global_side_data;
5557 };
5658
5759 #ifdef __GNUC__
libavformat/utils.c+16−3
@@ -110,6 +110,16 @@ MAKE_ACCESSORS(AVFormatContext, format, int, metadata_header_padding) · 109 unmodified lines
110110 MAKE_ACCESSORS(AVFormatContext, format, void *, opaque)
111111 MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb)
112112
113+void av_format_inject_global_side_data(AVFormatContext *s)
114+{
115+ int i;
116+ s->internal->inject_global_side_data = 1;
117+ for (i = 0; i < s->nb_streams; i++) {
118+ AVStream *st = s->streams[i];
119+ st->inject_global_side_data = 1;
120+ }
121+}
122+
113123 static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
114124 {
115125 if (st->codec->codec)
@@ -1527,7 +1537,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1411 unmodified lines
15271537 st->skip_samples = 0;
15281538 }
15291539
1530− if (!st->global_side_data_injected) {
1540+ if (st->inject_global_side_data) {
15311541 for (i = 0; i < st->nb_side_data; i++) {
15321542 AVPacketSideData *src_sd = &st->side_data[i];
15331543 uint8_t *dst_data;
@@ -1543,7 +1553,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 9 unmodified lines
15431553
15441554 memcpy(dst_data, src_sd->data, src_sd->size);
15451555 }
1546− st->global_side_data_injected = 1;
1556+ st->inject_global_side_data = 0;
15471557 }
15481558
15491559 if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA))
@@ -1717,7 +1727,8 @@ void ff_read_frame_flush(AVFormatContext *s) · 167 unmodified lines
17171727 for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
17181728 st->pts_buffer[j] = AV_NOPTS_VALUE;
17191729
1720− st->global_side_data_injected = 0;
1730+ if (s->internal->inject_global_side_data)
1731+ st->inject_global_side_data = 1;
17211732 }
17221733 }
17231734
@@ -3690,6 +3701,8 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) · 1966 unmodified lines
36903701 st->info->fps_first_dts = AV_NOPTS_VALUE;
36913702 st->info->fps_last_dts = AV_NOPTS_VALUE;
36923703
3704+ st->inject_global_side_data = s->internal->inject_global_side_data;
3705+
36933706 s->streams[s->nb_streams++] = st;
36943707 return st;
36953708 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t