History

lavc: add channels field to AVFrame

This is required otherwise it is not always possible to guess the number of channels from the layout, for example if the channel layout is unknown.

Stefano Sabatini committed 14 years ago

Commit 23fc4dd1 parent b4c33594 files · +19 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavcodec/avcodec.h +11 −0
  3. libavcodec/utils.c +4 −0
  4. libavcodec/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2011-04-18 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2012-07-31 - xxxxxxx - lavc 54.46.100
19+ Add channels field to AVFrame.
20+
1821 2012-07-30 - xxxxxxx - lavu 51.66.100
1922 Add av_get_channel_description()
2023 and av_get_standard_channel_layout() functions.
libavcodec/avcodec.h+11−0
@@ -1337,6 +1337,15 @@ typedef struct AVFrame { · 1336 unmodified lines
13371337 int decode_error_flags;
13381338 #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
13391339 #define FF_DECODE_ERROR_MISSING_REFERENCE 2
1340+
1341+ /**
1342+ * number of audio channels, only used for audio.
1343+ * Code outside libavcodec should access this field using:
1344+ * av_frame_get_channels(frame)
1345+ * - encoding: unused
1346+ * - decoding: Read by user.
1347+ */
1348+ int64_t channels;
13401349 } AVFrame;
13411350
13421351 /**
@@ -1352,6 +1361,8 @@ int64_t av_frame_get_pkt_pos (const AVFrame *frame); · 9 unmodified lines
13521361 void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
13531362 int64_t av_frame_get_channel_layout (const AVFrame *frame);
13541363 void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
1364+int av_frame_get_channels (const AVFrame *frame);
1365+void av_frame_set_channels (AVFrame *frame, int val);
13551366 int av_frame_get_sample_rate (const AVFrame *frame);
13561367 void av_frame_set_sample_rate (AVFrame *frame, int val);
13571368 AVDictionary *av_frame_get_metadata (const AVFrame *frame);
libavcodec/utils.c+4−0
@@ -427,6 +427,7 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) · 426 unmodified lines
427427 frame->sample_rate = avctx->sample_rate;
428428 frame->format = avctx->sample_fmt;
429429 frame->channel_layout = avctx->channel_layout;
430+ frame->channels = avctx->channels;
430431
431432 if (avctx->debug & FF_DEBUG_BUFFERS)
432433 av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, "
@@ -724,6 +725,7 @@ MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp) · 291 unmodified lines
724725 MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration)
725726 MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos)
726727 MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout)
728+MAKE_ACCESSORS(AVFrame, frame, int, channels)
727729 MAKE_ACCESSORS(AVFrame, frame, int, sample_rate)
728730 MAKE_ACCESSORS(AVFrame, frame, AVDictionary *, metadata)
729731 MAKE_ACCESSORS(AVFrame, frame, int, decode_error_flags)
@@ -1648,6 +1650,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, · 918 unmodified lines
16481650 frame->format = avctx->sample_fmt;
16491651 if (!frame->channel_layout)
16501652 frame->channel_layout = avctx->channel_layout;
1653+ if (!frame->channels)
1654+ frame->channels = avctx->channels;
16511655 if (!frame->sample_rate)
16521656 frame->sample_rate = avctx->sample_rate;
16531657 }
libavcodec/version.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 */
2828
2929 #define LIBAVCODEC_VERSION_MAJOR 54
30−#define LIBAVCODEC_VERSION_MINOR 45
30+#define LIBAVCODEC_VERSION_MINOR 46
3131 #define LIBAVCODEC_VERSION_MICRO 100
3232
3333 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

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