summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-03-04 23:57:30 +0000
committerMark Thompson <sw@jkqxz.net>2017-06-14 22:26:32 +0100
commit06043cc0bc72b530db352a67776392cf61a54104 (patch)
treea231ad41bad12b7ab393981b59a0eee1accb5b44 /ffmpeg.c
parent0b1794a43e1083644aa3db2a09323681cfe080ec (diff)
ffmpeg: Generic device setup
Not yet enabled for any hwaccels. (cherry picked from commit d2e6dd32a445b5744a51d090c0822dbd7e434592) (cherry picked from commit 9203aac22874c7259e155b7d00f1f33bb1355129)
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index cd19594f8b..6170bd453c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2884,6 +2884,15 @@ static int init_input_stream(int ist_index, char *error, int error_len)
if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
+
+ ret = hw_device_setup_for_decode(ist);
+ if (ret < 0) {
+ snprintf(error, error_len, "Device setup failed for "
+ "decoder on input stream #%d:%d : %s",
+ ist->file_index, ist->st->index, av_err2str(ret));
+ return ret;
+ }
+
if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
abort_codec_experimental(codec, 0);
@@ -3441,6 +3450,14 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
ost->enc_ctx->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(ost->filter->filter));
if (!ost->enc_ctx->hw_frames_ctx)
return AVERROR(ENOMEM);
+ } else {
+ ret = hw_device_setup_for_encode(ost);
+ if (ret < 0) {
+ snprintf(error, error_len, "Device setup failed for "
+ "encoder on output stream #%d:%d : %s",
+ ost->file_index, ost->index, av_err2str(ret));
+ return ret;
+ }
}
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
@@ -4643,6 +4660,7 @@ static int transcode(void)
}
av_buffer_unref(&hw_device_ctx);
+ hw_device_free_all();
/* finished ! */
ret = 0;