Originally committed as revision 22751 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -515,6 +515,7 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) · 514 unmodified lines | ||
| 515 | 515 | s->nb_streams = ic->nb_streams; |
| 516 | 516 | for(i=0;i<ic->nb_streams;i++) { |
| 517 | 517 | AVStream *st; |
| 518 | + AVCodec *codec; | |
| 518 | 519 | |
| 519 | 520 | // FIXME: a more elegant solution is needed |
| 520 | 521 | st = av_mallocz(sizeof(AVStream)); |
| @@ -524,13 +525,21 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename) · 3 unmodified lines | ||
| 524 | 525 | print_error(filename, AVERROR(ENOMEM)); |
| 525 | 526 | av_exit(1); |
| 526 | 527 | } |
| 527 | − memcpy(st->codec, ic->streams[i]->codec, sizeof(AVCodecContext)); | |
| 528 | + avcodec_copy_context(st->codec, ic->streams[i]->codec); | |
| 528 | 529 | s->streams[i] = st; |
| 529 | 530 | |
| 530 | − if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && audio_stream_copy) | |
| 531 | − st->stream_copy = 1; | |
| 532 | − else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && video_stream_copy) | |
| 533 | − st->stream_copy = 1; | |
| 531 | + codec = avcodec_find_encoder(st->codec->codec_id); | |
| 532 | + if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { | |
| 533 | + if (audio_stream_copy) { | |
| 534 | + st->stream_copy = 1; | |
| 535 | + } else | |
| 536 | + choose_sample_fmt(st, codec); | |
| 537 | + } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { | |
| 538 | + if (video_stream_copy) { | |
| 539 | + st->stream_copy = 1; | |
| 540 | + } else | |
| 541 | + choose_pixel_fmt(st, codec); | |
| 542 | + } | |
| 534 | 543 | |
| 535 | 544 | if(!st->codec->thread_count) |
| 536 | 545 | st->codec->thread_count = 1; |
| @@ -4039,7 +4039,6 @@ static int parse_ffconfig(const char *filename) · 4038 unmodified lines | ||
| 4039 | 4039 | filename, line_num); |
| 4040 | 4040 | } else { |
| 4041 | 4041 | FFStream *s; |
| 4042 | − const AVClass *class; | |
| 4043 | 4042 | stream = av_mallocz(sizeof(FFStream)); |
| 4044 | 4043 | get_arg(stream->filename, sizeof(stream->filename), &p); |
| 4045 | 4044 | q = strrchr(stream->filename, '>'); |
| @@ -4055,15 +4054,8 @@ static int parse_ffconfig(const char *filename) · 9 unmodified lines | ||
| 4055 | 4054 | } |
| 4056 | 4055 | |
| 4057 | 4056 | stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL); |
| 4058 | − /* fetch avclass so AVOption works | |
| 4059 | − * FIXME try to use avcodec_get_context_defaults2 | |
| 4060 | − * without changing defaults too much */ | |
| 4061 | − avcodec_get_context_defaults(&video_enc); | |
| 4062 | − class = video_enc.av_class; | |
| 4063 | − memset(&audio_enc, 0, sizeof(AVCodecContext)); | |
| 4064 | − memset(&video_enc, 0, sizeof(AVCodecContext)); | |
| 4065 | − audio_enc.av_class = class; | |
| 4066 | − video_enc.av_class = class; | |
| 4057 | + avcodec_get_context_defaults2(&video_enc, AVMEDIA_TYPE_VIDEO); | |
| 4058 | + avcodec_get_context_defaults2(&audio_enc, AVMEDIA_TYPE_AUDIO); | |
| 4067 | 4059 | audio_id = CODEC_ID_NONE; |
| 4068 | 4060 | video_id = CODEC_ID_NONE; |
| 4069 | 4061 | if (stream->fmt) { |