avconv: move resample_{width,height,pix_fmt} to InputStream.
This is a more proper place for them, since they store parameters of the input, not output, stream.
This commit is contained in:
parent
9dced85426
commit
e77c86629f
49
avconv.c
49
avconv.c
@ -179,6 +179,10 @@ typedef struct InputStream {
|
|||||||
int showed_multi_packet_warning;
|
int showed_multi_packet_warning;
|
||||||
AVDictionary *opts;
|
AVDictionary *opts;
|
||||||
|
|
||||||
|
int resample_height;
|
||||||
|
int resample_width;
|
||||||
|
int resample_pix_fmt;
|
||||||
|
|
||||||
/* a pool of free buffers for decoded data */
|
/* a pool of free buffers for decoded data */
|
||||||
FrameBuffer *buffer_pool;
|
FrameBuffer *buffer_pool;
|
||||||
} InputStream;
|
} InputStream;
|
||||||
@ -215,9 +219,6 @@ typedef struct OutputStream {
|
|||||||
AVFrame *output_frame;
|
AVFrame *output_frame;
|
||||||
|
|
||||||
/* video only */
|
/* video only */
|
||||||
int resample_height;
|
|
||||||
int resample_width;
|
|
||||||
int resample_pix_fmt;
|
|
||||||
AVRational frame_rate;
|
AVRational frame_rate;
|
||||||
int force_fps;
|
int force_fps;
|
||||||
int top_field_first;
|
int top_field_first;
|
||||||
@ -1869,7 +1870,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
|
|||||||
{
|
{
|
||||||
AVFrame *decoded_frame, *filtered_frame = NULL;
|
AVFrame *decoded_frame, *filtered_frame = NULL;
|
||||||
void *buffer_to_free = NULL;
|
void *buffer_to_free = NULL;
|
||||||
int i, ret = 0;
|
int i, ret = 0, resample_changed;
|
||||||
float quality;
|
float quality;
|
||||||
int frame_available = 1;
|
int frame_available = 1;
|
||||||
|
|
||||||
@ -1902,32 +1903,34 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
|
|||||||
if (ist->st->sample_aspect_ratio.num)
|
if (ist->st->sample_aspect_ratio.num)
|
||||||
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
|
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
|
||||||
|
|
||||||
for (i = 0; i < nb_output_streams; i++) {
|
resample_changed = ist->resample_width != decoded_frame->width ||
|
||||||
OutputStream *ost = output_streams[i];
|
ist->resample_height != decoded_frame->height ||
|
||||||
int frame_size, resample_changed;
|
ist->resample_pix_fmt != decoded_frame->format;
|
||||||
|
|
||||||
if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
resample_changed = ost->resample_width != decoded_frame->width ||
|
|
||||||
ost->resample_height != decoded_frame->height ||
|
|
||||||
ost->resample_pix_fmt != decoded_frame->format;
|
|
||||||
if (resample_changed) {
|
if (resample_changed) {
|
||||||
av_log(NULL, AV_LOG_INFO,
|
av_log(NULL, AV_LOG_INFO,
|
||||||
"Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
|
"Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
|
||||||
ist->file_index, ist->st->index,
|
ist->file_index, ist->st->index,
|
||||||
ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt),
|
ist->resample_width, ist->resample_height, av_get_pix_fmt_name(ist->resample_pix_fmt),
|
||||||
decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format));
|
decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format));
|
||||||
|
|
||||||
|
ist->resample_width = decoded_frame->width;
|
||||||
|
ist->resample_height = decoded_frame->height;
|
||||||
|
ist->resample_pix_fmt = decoded_frame->format;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < nb_output_streams; i++) {
|
||||||
|
OutputStream *ost = output_streams[i];
|
||||||
|
int frame_size;
|
||||||
|
|
||||||
|
if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (resample_changed) {
|
||||||
avfilter_graph_free(&ost->graph);
|
avfilter_graph_free(&ost->graph);
|
||||||
if (configure_video_filters(ist, ost)) {
|
if (configure_video_filters(ist, ost)) {
|
||||||
av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n");
|
av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n");
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ost->resample_width = decoded_frame->width;
|
|
||||||
ost->resample_height = decoded_frame->height;
|
|
||||||
ost->resample_pix_fmt = decoded_frame->format;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ist->st->codec->codec->capabilities & CODEC_CAP_DR1) {
|
if (ist->st->codec->codec->capabilities & CODEC_CAP_DR1) {
|
||||||
@ -2427,10 +2430,6 @@ static int transcode_init(void)
|
|||||||
codec->bits_per_raw_sample = 0;
|
codec->bits_per_raw_sample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ost->resample_height = icodec->height;
|
|
||||||
ost->resample_width = icodec->width;
|
|
||||||
ost->resample_pix_fmt = icodec->pix_fmt;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_SUBTITLE:
|
case AVMEDIA_TYPE_SUBTITLE:
|
||||||
codec->time_base = (AVRational){1, 1000};
|
codec->time_base = (AVRational){1, 1000};
|
||||||
@ -3136,6 +3135,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
dec->width >>= dec->lowres;
|
dec->width >>= dec->lowres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ist->resample_height = dec->height;
|
||||||
|
ist->resample_width = dec->width;
|
||||||
|
ist->resample_pix_fmt = dec->pix_fmt;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
case AVMEDIA_TYPE_DATA:
|
case AVMEDIA_TYPE_DATA:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user