ffmpeg.c: store per-output stream sws flags.
This commit is contained in:
parent
6bb6fb05ba
commit
1435f2fa72
16
ffmpeg.c
16
ffmpeg.c
@ -245,8 +245,6 @@ static char *forced_key_frames = NULL;
|
|||||||
|
|
||||||
static float dts_delta_threshold = 10;
|
static float dts_delta_threshold = 10;
|
||||||
|
|
||||||
static unsigned int sws_flags = SWS_BICUBIC;
|
|
||||||
|
|
||||||
static int64_t timer_start;
|
static int64_t timer_start;
|
||||||
|
|
||||||
static uint8_t *audio_buf;
|
static uint8_t *audio_buf;
|
||||||
@ -303,6 +301,8 @@ typedef struct AVOutputStream {
|
|||||||
AVAudioConvert *reformat_ctx;
|
AVAudioConvert *reformat_ctx;
|
||||||
AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */
|
AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */
|
||||||
FILE *logfile;
|
FILE *logfile;
|
||||||
|
|
||||||
|
int sws_flags;
|
||||||
} AVOutputStream;
|
} AVOutputStream;
|
||||||
|
|
||||||
static AVOutputStream **output_streams_for_file[MAX_FILES] = { NULL };
|
static AVOutputStream **output_streams_for_file[MAX_FILES] = { NULL };
|
||||||
@ -378,7 +378,7 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
|
|||||||
snprintf(args, 255, "%d:%d:flags=0x%X",
|
snprintf(args, 255, "%d:%d:flags=0x%X",
|
||||||
codec->width,
|
codec->width,
|
||||||
codec->height,
|
codec->height,
|
||||||
(int)av_get_int(sws_opts, "sws_flags", NULL));
|
ost->sws_flags);
|
||||||
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
|
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
|
||||||
NULL, args, NULL, graph)) < 0)
|
NULL, args, NULL, graph)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -387,7 +387,7 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
|
|||||||
last_filter = filter;
|
last_filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL));
|
snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags);
|
||||||
graph->scale_sws_opts = av_strdup(args);
|
graph->scale_sws_opts = av_strdup(args);
|
||||||
|
|
||||||
if (vfilters) {
|
if (vfilters) {
|
||||||
@ -617,6 +617,8 @@ static AVOutputStream *new_output_stream(AVFormatContext *oc, int file_idx)
|
|||||||
}
|
}
|
||||||
ost->file_index = file_idx;
|
ost->file_index = file_idx;
|
||||||
ost->index = idx;
|
ost->index = idx;
|
||||||
|
|
||||||
|
ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
|
||||||
return ost;
|
return ost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,7 +1143,6 @@ static void do_video_out(AVFormatContext *s,
|
|||||||
|
|
||||||
/* initialize a new scaler context */
|
/* initialize a new scaler context */
|
||||||
sws_freeContext(ost->img_resample_ctx);
|
sws_freeContext(ost->img_resample_ctx);
|
||||||
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
|
|
||||||
ost->img_resample_ctx = sws_getContext(
|
ost->img_resample_ctx = sws_getContext(
|
||||||
ist->st->codec->width,
|
ist->st->codec->width,
|
||||||
ist->st->codec->height,
|
ist->st->codec->height,
|
||||||
@ -1149,7 +1150,7 @@ static void do_video_out(AVFormatContext *s,
|
|||||||
ost->st->codec->width,
|
ost->st->codec->width,
|
||||||
ost->st->codec->height,
|
ost->st->codec->height,
|
||||||
ost->st->codec->pix_fmt,
|
ost->st->codec->pix_fmt,
|
||||||
sws_flags, NULL, NULL, NULL);
|
ost->sws_flags, NULL, NULL, NULL);
|
||||||
if (ost->img_resample_ctx == NULL) {
|
if (ost->img_resample_ctx == NULL) {
|
||||||
fprintf(stderr, "Cannot get resampling context\n");
|
fprintf(stderr, "Cannot get resampling context\n");
|
||||||
ffmpeg_exit(1);
|
ffmpeg_exit(1);
|
||||||
@ -2177,7 +2178,6 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
|
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
|
||||||
ffmpeg_exit(1);
|
ffmpeg_exit(1);
|
||||||
}
|
}
|
||||||
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
|
|
||||||
ost->img_resample_ctx = sws_getContext(
|
ost->img_resample_ctx = sws_getContext(
|
||||||
icodec->width,
|
icodec->width,
|
||||||
icodec->height,
|
icodec->height,
|
||||||
@ -2185,7 +2185,7 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
codec->width,
|
codec->width,
|
||||||
codec->height,
|
codec->height,
|
||||||
codec->pix_fmt,
|
codec->pix_fmt,
|
||||||
sws_flags, NULL, NULL, NULL);
|
ost->sws_flags, NULL, NULL, NULL);
|
||||||
if (ost->img_resample_ctx == NULL) {
|
if (ost->img_resample_ctx == NULL) {
|
||||||
fprintf(stderr, "Cannot get resampling context\n");
|
fprintf(stderr, "Cannot get resampling context\n");
|
||||||
ffmpeg_exit(1);
|
ffmpeg_exit(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user