annotate av_helpers.c @ 36545:f0e92381681d

Add support for files with MLTI chunks. Fixes 06.rm and 08_lect_01.rm from FFmpeg trac #2152 Fixes also files from ftp://ftp.aduni.org/videos/ The patch has these limitations: - no multirate files with MLTI chunks - no mixed files (eg. MLTI for audio but not for video) - no MLTI for video together with non-ra audio (eg. ralf) - only DATA v0 (no v1, versions greater than 1 should not exist) Files with these feature shuld not really exist anyway. Also video MLTI files with only one stream are supported but untested
author rtogni
date Sun, 19 Jan 2014 15:12:46 +0000
parents d9d308031e9e
children 636c79b71de9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33886
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
1 /*
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
2 * Generic libav* helpers
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
3 *
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
4 * This file is part of MPlayer.
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
5 *
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
7 * it under the terms of the GNU General Public License as published by
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
9 * (at your option) any later version.
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
10 *
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
14 * GNU General Public License for more details.
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
15 *
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
16 * You should have received a copy of the GNU General Public License along
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
19 */
5f1faa91717e Add license boilerplate.
reimar
parents: 33871
diff changeset
20
33871
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
21 #include "libavcodec/avcodec.h"
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
22 #include "libavformat/avformat.h"
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
23 #include "mp_msg.h"
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
24 #include "av_helpers.h"
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
25 #include "libaf/reorder_ch.h"
33871
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
26
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
27 int avcodec_initialized;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
28 int avformat_initialized;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
29
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
30 static void mp_msp_av_log_callback(void *ptr, int level, const char *fmt,
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
31 va_list vl)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
32 {
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
33 static int print_prefix=1;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
34 AVClass *avc= ptr ? *(AVClass **)ptr : NULL;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
35 int type= MSGT_FIXME;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
36 int mp_level;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
37
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
38 switch(level){
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
39 case AV_LOG_VERBOSE: mp_level = MSGL_V ; break;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
40 case AV_LOG_DEBUG: mp_level= MSGL_V ; break;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
41 case AV_LOG_INFO : mp_level= MSGL_INFO; break;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
42 case AV_LOG_ERROR: mp_level= MSGL_ERR ; break;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
43 default : mp_level= level > AV_LOG_DEBUG ? MSGL_DBG2 : MSGL_ERR; break;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
44 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
45
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
46 if (ptr && !avc)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
47 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "libav* called av_log with context containing a broken AVClass!\n");
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
48 if (avc) {
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
49 if(!strcmp(avc->class_name, "AVCodecContext")){
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
50 AVCodecContext *s= ptr;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
51 if(s->codec){
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
52 if(s->codec->type == AVMEDIA_TYPE_AUDIO){
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
53 if(s->codec->decode)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
54 type= MSGT_DECAUDIO;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
55 }else if(s->codec->type == AVMEDIA_TYPE_VIDEO){
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
56 if(s->codec->decode)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
57 type= MSGT_DECVIDEO;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
58 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
59 //FIXME subtitles, encoders (what msgt for them? there is no appropriate ...)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
60 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
61 }else if(!strcmp(avc->class_name, "AVFormatContext")){
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
62 AVFormatContext *s= ptr;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
63 if(s->iformat)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
64 type= MSGT_DEMUXER;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
65 else if(s->oformat)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
66 type= MSGT_MUXER;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
67 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
68 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
69
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
70 if (!mp_msg_test(type, mp_level)) return;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
71
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
72 if(print_prefix && avc) {
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
73 mp_msg(type, mp_level, "[%s @ %p]", avc->item_name(ptr), avc);
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
74 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
75
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
76 print_prefix= strchr(fmt, '\n') != NULL;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
77 mp_msg_va(type, mp_level, fmt, vl);
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
78 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
79
34377
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
80 static void show_av_version(int type, const char *name,
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
81 int header_ver, int ver, const char *conf)
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
82 {
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
83 #ifdef CONFIG_FFMPEG_SO
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
84 #define FFMPEG_TYPE "external"
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
85 #else
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
86 #define FFMPEG_TYPE "internal"
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
87 #endif
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
88 mp_msg(type, MSGL_INFO, "%s version %d.%d.%d (" FFMPEG_TYPE ")\n",
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
89 name, ver >> 16, (ver >> 8) & 0xFF, ver & 0xFF);
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
90 if (header_ver != ver)
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
91 mp_msg(type, MSGL_INFO, "Mismatching header version %d.%d.%d\n",
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
92 header_ver >> 16, (header_ver >> 8) & 0xFF, header_ver & 0xFF);
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
93 mp_msg(type, MSGL_V, "Configuration: %s\n", conf);
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
94 }
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
95
33871
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
96 void init_avcodec(void)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
97 {
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
98 if (!avcodec_initialized) {
34377
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
99 show_av_version(MSGT_DECVIDEO, "libavcodec", LIBAVCODEC_VERSION_INT,
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
100 avcodec_version(), avcodec_configuration());
33871
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
101 avcodec_register_all();
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
102 avcodec_initialized = 1;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
103 av_log_set_callback(mp_msp_av_log_callback);
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
104 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
105 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
106
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
107 void init_avformat(void)
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
108 {
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
109 if (!avformat_initialized) {
34377
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
110 show_av_version(MSGT_DEMUX, "libavformat", LIBAVFORMAT_VERSION_INT,
d443d66a746c av_helpers: show libav* version and configuration.
cigaes
parents: 34376
diff changeset
111 avformat_version(), avformat_configuration());
33871
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
112 av_register_all();
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
113 avformat_initialized = 1;
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
114 av_log_set_callback(mp_msp_av_log_callback);
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
115 }
30f5e5cd3676 Move code for setting up libav* logging callbacks from vd_ffmpeg to a
reimar
parents:
diff changeset
116 }
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
117
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
118 int lavc_encode_audio(AVCodecContext *ctx, void *src, int src_len, void *dst, int dst_len)
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
119 {
36335
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
120 void *orig_src = src;
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
121 int bps = av_get_bytes_per_sample(ctx->sample_fmt);
36335
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
122 int planar = ctx->channels > 1 && av_sample_fmt_is_planar(ctx->sample_fmt);
36338
d9d308031e9e Fix channel reordering for ac3_fixed encoder.
reimar
parents: 36335
diff changeset
123 int isac3 = ctx->codec->id == AV_CODEC_ID_AC3;
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
124 int n;
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
125 int got;
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
126 AVPacket pkt;
36335
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
127 AVFrame *frame = avcodec_alloc_frame();
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
128 if ((ctx->channels == 6 || ctx->channels == 5) &&
36338
d9d308031e9e Fix channel reordering for ac3_fixed encoder.
reimar
parents: 36335
diff changeset
129 (isac3 || !strcmp(ctx->codec->name,"libfaac"))) {
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
130 reorder_channel_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
131 isac3 ? AF_CHANNEL_LAYOUT_LAVC_DEFAULT : AF_CHANNEL_LAYOUT_AAC_DEFAULT,
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
132 ctx->channels,
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
133 src_len / bps, bps);
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
134 }
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
135 pkt.data = dst;
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
136 pkt.size = dst_len;
36335
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
137 frame->nb_samples = src_len / ctx->channels / bps;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
138 if (planar) {
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
139 // TODO: this is horribly inefficient.
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
140 int ch;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
141 src = av_mallocz(src_len);
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
142 for (ch = 0; ch < ctx->channels; ch++) {
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
143 uint8_t *tmps = (uint8_t *)orig_src + ch*bps;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
144 uint8_t *tmpd = (uint8_t *)src + ch*src_len/ctx->channels;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
145 int s;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
146 for (s = 0; s < frame->nb_samples; s++) {
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
147 memcpy(tmpd, tmps, bps);
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
148 tmps += ctx->channels * bps;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
149 tmpd += bps;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
150 }
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
151 }
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
152 }
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
153 n = avcodec_fill_audio_frame(frame, ctx->channels, ctx->sample_fmt, src, src_len, 1);
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
154 if (n < 0) return 0;
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
155 n = avcodec_encode_audio2(ctx, &pkt, frame, &got);
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
156 avcodec_free_frame(&frame);
f77a74ebb95e Quick an inefficient hack to enable planar encoding.
reimar
parents: 36334
diff changeset
157 if (planar) av_free(src);
36334
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
158 if (n < 0) return n;
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
159 return got ? pkt.size : 0;
c1033e9288b1 Extract audio encoding code into a separate helper function.
reimar
parents: 34377
diff changeset
160 }