[FFmpeg-soc] [soc]: r4699 - in concat: ffmpeg.c.diff ffplay.c.diff libavformat/playlist.c
gkovacs
subversion at mplayerhq.hu
Mon Jul 13 07:03:52 CEST 2009
Author: gkovacs
Date: Mon Jul 13 07:03:52 2009
New Revision: 4699
Log:
moved codec opening back to on-demand model to fix conc option
Modified:
concat/ffmpeg.c.diff
concat/ffplay.c.diff
concat/libavformat/playlist.c
Modified: concat/ffmpeg.c.diff
==============================================================================
--- concat/ffmpeg.c.diff Mon Jul 13 04:28:39 2009 (r4698)
+++ concat/ffmpeg.c.diff Mon Jul 13 07:03:52 2009 (r4699)
@@ -1,5 +1,5 @@
diff --git a/ffmpeg.c b/ffmpeg.c
-index 22bfed8..b34db3a 100644
+index 22bfed8..2526240 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -70,6 +70,8 @@
@@ -32,16 +32,33 @@ index 22bfed8..b34db3a 100644
{
AVFormatContext *os;
AVOutputStream *ost;
-@@ -1250,6 +1257,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
+@@ -1250,7 +1257,24 @@ static int output_packet(AVInputStream *ist, int ist_index,
AVSubtitle subtitle, *subtitle_to_free;
int got_subtitle;
AVPacket avpkt;
-+ if (ist && is && pkt && is->nb_streams > pkt->stream_index && is->streams && is->streams[pkt->stream_index] && is->streams[pkt->stream_index]->codec)
+-
++ if (ist && is && pkt && is->iformat && is->iformat->long_name &&
++ !strncmp(is->iformat->long_name, "CONCAT", 6) && is->nb_streams > pkt->stream_index &&
++ is->streams && is->streams[pkt->stream_index] && is->streams[pkt->stream_index]->codec) {
+ ist->st = is->streams[pkt->stream_index];
-
++ if (!ist->st->codec->codec) {
++ AVCodec *codec = avcodec_find_decoder(ist->st->codec->codec_id);
++ if (!codec) {
++ fprintf(stderr, "output_packet: Decoder (codec id %d) not found for input stream #%d.%d\n",
++ ist->st->codec->codec_id, ist->file_index, ist->index);
++ return AVERROR(EINVAL);
++ }
++ if (avcodec_open(ist->st->codec, codec) < 0) {
++ fprintf(stderr, "output_packet: Error while opening decoder for input stream #%d.%d\n",
++ ist->file_index, ist->index);
++ return AVERROR(EINVAL);
++ }
++ }
++ }
if(ist->next_pts == AV_NOPTS_VALUE)
ist->next_pts= ist->pts;
-@@ -1644,6 +1653,7 @@ static int av_encode(AVFormatContext **output_files,
+
+@@ -1644,6 +1668,7 @@ static int av_encode(AVFormatContext **output_files,
uint8_t no_packet[MAX_FILES]={0};
int no_packet_count=0;
@@ -49,7 +66,7 @@ index 22bfed8..b34db3a 100644
file_table= av_mallocz(nb_input_files * sizeof(AVInputFile));
if (!file_table)
goto fail;
-@@ -2278,8 +2288,7 @@ static int av_encode(AVFormatContext **output_files,
+@@ -2278,8 +2303,7 @@ static int av_encode(AVFormatContext **output_files,
}
//fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);
@@ -59,7 +76,7 @@ index 22bfed8..b34db3a 100644
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->index);
-@@ -2300,7 +2309,7 @@ static int av_encode(AVFormatContext **output_files,
+@@ -2300,7 +2324,7 @@ static int av_encode(AVFormatContext **output_files,
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
@@ -68,7 +85,7 @@ index 22bfed8..b34db3a 100644
}
}
-@@ -2848,6 +2857,7 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder)
+@@ -2848,6 +2872,7 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder)
static void opt_input_file(const char *filename)
{
@@ -76,7 +93,7 @@ index 22bfed8..b34db3a 100644
AVFormatContext *ic;
AVFormatParameters params, *ap = ¶ms;
int err, i, ret, rfps, rfps_base;
-@@ -2859,6 +2869,43 @@ static void opt_input_file(const char *filename)
+@@ -2859,6 +2884,43 @@ static void opt_input_file(const char *filename)
using_stdin |= !strncmp(filename, "pipe:", 5) ||
!strcmp(filename, "/dev/stdin");
@@ -120,7 +137,7 @@ index 22bfed8..b34db3a 100644
/* get default parameters from command line */
ic = avformat_alloc_context();
-@@ -2925,6 +2972,8 @@ static void opt_input_file(const char *filename)
+@@ -2925,6 +2987,8 @@ static void opt_input_file(const char *filename)
start_time = 0;
}
@@ -129,7 +146,7 @@ index 22bfed8..b34db3a 100644
/* update the current parameters so that they match the one of the input stream */
for(i=0;i<ic->nb_streams;i++) {
AVCodecContext *enc = ic->streams[i]->codec;
-@@ -3000,6 +3049,8 @@ static void opt_input_file(const char *filename)
+@@ -3000,6 +3064,8 @@ static void opt_input_file(const char *filename)
dump_format(ic, nb_input_files, filename, 0);
nb_input_files++;
@@ -138,7 +155,7 @@ index 22bfed8..b34db3a 100644
file_iformat = NULL;
file_oformat = NULL;
-@@ -3874,6 +3925,7 @@ static const OptionDef options[] = {
+@@ -3874,6 +3940,7 @@ static const OptionDef options[] = {
{ "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" },
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
{ "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes}, "copy initial non-keyframes" },
Modified: concat/ffplay.c.diff
==============================================================================
--- concat/ffplay.c.diff Mon Jul 13 04:28:39 2009 (r4698)
+++ concat/ffplay.c.diff Mon Jul 13 07:03:52 2009 (r4699)
@@ -1,5 +1,5 @@
diff --git a/ffplay.c b/ffplay.c
-index 5f88a46..ca824b7 100644
+index 5f88a46..6f49788 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -30,6 +30,8 @@
@@ -11,7 +11,7 @@ index 5f88a46..ca824b7 100644
#include "cmdutils.h"
#include <SDL.h>
-@@ -1336,28 +1338,52 @@ static int video_thread(void *arg)
+@@ -1336,28 +1338,65 @@ static int video_thread(void *arg)
VideoState *is = arg;
AVPacket pkt1, *pkt = &pkt1;
int len1, got_picture;
@@ -56,6 +56,19 @@ index 5f88a46..ca824b7 100644
+// ++st_idx;
+// }
+ if (pkt->stream && pkt->stream->codec && pkt->stream->codec->codec_type == CODEC_TYPE_VIDEO) {
++ if (!pkt->stream->codec->codec) {
++ AVCodec *codec = avcodec_find_decoder(pkt->stream->codec->codec_id);
++ if (!codec) {
++ fprintf(stderr, "output_packet: Decoder (codec id %d) not found for input stream #%d\n",
++ pkt->stream->codec->codec_id, pkt->stream->index);
++ return AVERROR(EINVAL);
++ }
++ if (avcodec_open(pkt->stream->codec, codec) < 0) {
++ fprintf(stderr, "output_packet: Error while opening decoder for input stream #%d\n",
++ pkt->stream->index);
++ return AVERROR(EINVAL);
++ }
++ }
+ if (is->video_st != pkt->stream) {
+ is->video_st = pkt->stream;
+ goto tryagain;
@@ -67,7 +80,7 @@ index 5f88a46..ca824b7 100644
if( (decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE)
&& frame->reordered_opaque != AV_NOPTS_VALUE)
pts= frame->reordered_opaque;
-@@ -1366,9 +1392,6 @@ static int video_thread(void *arg)
+@@ -1366,9 +1405,6 @@ static int video_thread(void *arg)
else
pts= 0;
pts *= av_q2d(is->video_st->time_base);
@@ -77,7 +90,7 @@ index 5f88a46..ca824b7 100644
if (got_picture) {
if (output_picture2(is, frame, pts) < 0)
goto the_end;
-@@ -1561,50 +1584,63 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
+@@ -1561,50 +1597,76 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
{
AVPacket *pkt_temp = &is->audio_pkt_temp;
AVPacket *pkt = &is->audio_pkt;
@@ -104,6 +117,19 @@ index 5f88a46..ca824b7 100644
+ if (pl_ctx && pkt) {
+ AVStream *propst = ff_playlist_get_stream(pl_ctx, st_idx+1, pkt->stream_index);
+ if (propst && propst->codec && propst->codec->codec_type == CODEC_TYPE_AUDIO) {
++ if (!propst->codec->codec) {
++ AVCodec *codec = avcodec_find_decoder(propst->codec->codec_id);
++ if (!codec) {
++ fprintf(stderr, "output_packet: Decoder (codec id %d) not found for input stream #%d\n",
++ propst->codec->codec_id, propst->index);
++ return AVERROR(EINVAL);
++ }
++ if (avcodec_open(propst->codec, codec) < 0) {
++ fprintf(stderr, "output_packet: Error while opening decoder for input stream #%d\n",
++ propst->index);
++ return AVERROR(EINVAL);
++ }
++ }
+ is->audio_st = propst;
+ ++st_idx;
+ }
@@ -153,7 +179,7 @@ index 5f88a46..ca824b7 100644
break;
}
is->audio_buf= is->audio_buf2;
-@@ -1618,9 +1654,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
+@@ -1618,9 +1680,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
/* if no pts, then compute it */
pts = is->audio_clock;
*pts_ptr = pts;
@@ -165,7 +191,7 @@ index 5f88a46..ca824b7 100644
#if defined(DEBUG_SYNC)
{
static double last_clock;
-@@ -1632,7 +1668,6 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
+@@ -1632,7 +1694,6 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
#endif
return data_size;
}
@@ -173,7 +199,7 @@ index 5f88a46..ca824b7 100644
/* free the current packet */
if (pkt->data)
av_free_packet(pkt);
-@@ -1645,7 +1680,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
+@@ -1645,7 +1706,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
if (packet_queue_get(&is->audioq, pkt, 1) < 0)
return -1;
if(pkt->data == flush_pkt.data){
Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c Mon Jul 13 04:28:39 2009 (r4698)
+++ concat/libavformat/playlist.c Mon Jul 13 07:03:52 2009 (r4699)
@@ -52,19 +52,6 @@ int ff_playlist_init_playelem(PlayElem *
else {
av_log(pe->ic, AV_LOG_ERROR, "ByteIOContext not set\n");
}
- for (i = 0; i < pe->ic->nb_streams; ++i) {
- AVCodec *codec = avcodec_find_decoder(pe->ic->streams[i]->codec->codec_id);
- if (!codec) {
- av_log(pe->ic->streams[i]->codec, AV_LOG_ERROR, "Decoder (codec id %d) not found for input stream #%d\n",
- pe->ic->streams[i]->codec->codec_id, i);
- return AVERROR(EINVAL);
- }
- if (avcodec_open(pe->ic->streams[i]->codec, codec) < 0) {
- av_log(pe->ic->streams[i]->codec, AV_LOG_ERROR, "Error while opening decoder for input stream #%d\n",
- i);
- return AVERROR(EINVAL);
- }
- }
return 0;
}
More information about the FFmpeg-soc
mailing list