summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2010-11-13 13:57:49 +0000
committerAurelien Jacobs <aurel@gnuage.org>2010-11-13 13:57:49 +0000
commitcb2c971d91ef166914a4982e941aa71ffd496610 (patch)
treec9be6025b40a978ff442d052a722e0b82e6862bb /ffmpeg.c
parent2722dd6ebf9d93ab097c303df1d789f6074121c8 (diff)
downloadffmpeg-cb2c971d91ef166914a4982e941aa71ffd496610.tar.gz
allow passing subtitles header between decoder and encoder
Originally committed as revision 25745 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 017679ca8a..1eac3cdae8 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2284,6 +2284,7 @@ static int transcode(AVFormatContext **output_files,
ost = ost_table[i];
if (ost->encoding_needed) {
AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL;
+ AVCodecContext *dec = ist_table[ost->source_index]->st->codec;
if (!codec)
codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) {
@@ -2292,6 +2293,15 @@ static int transcode(AVFormatContext **output_files,
ret = AVERROR(EINVAL);
goto dump_format;
}
+ if (dec->subtitle_header) {
+ ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
+ if (!ost->st->codec->subtitle_header) {
+ ret = AVERROR(ENOMEM);
+ goto dump_format;
+ }
+ memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
+ ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
+ }
if (avcodec_open(ost->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
@@ -2690,6 +2700,7 @@ static int transcode(AVFormatContext **output_files,
}
av_fifo_free(ost->fifo); /* works even if fifo is not
initialized but set to zero */
+ av_freep(&ost->st->codec->subtitle_header);
av_free(ost->pict_tmp.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)