mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-20 01:50:26 -05:00
Cleaning up deprecated ffmpeg/libav
This commit is contained in:
@@ -136,7 +136,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 54 || (LIBAVCODEC_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 6)
|
||||
ret = avcodec_open2(src, img_decoder, NULL);
|
||||
#else
|
||||
ret = avcodec_open(src, img_decoder);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Could not open codec for decoding: %s\n", strerror(AVUNERROR(ret)));
|
||||
@@ -209,7 +213,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 21)
|
||||
dst_st = avformat_new_stream(dst_ctx, NULL);
|
||||
#else
|
||||
dst_st = av_new_stream(dst_ctx, 0);
|
||||
#endif
|
||||
if (!dst_st)
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Out of memory for new output stream\n");
|
||||
@@ -220,10 +228,10 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma
|
||||
|
||||
dst = dst_st->codec;
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64)
|
||||
avcodec_get_context_defaults2(dst, AVMEDIA_TYPE_VIDEO);
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 54 || (LIBAVCODEC_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 35)
|
||||
avcodec_get_context_defaults3(dst, NULL);
|
||||
#else
|
||||
avcodec_get_context_defaults2(dst, CODEC_TYPE_VIDEO);
|
||||
avcodec_get_context_defaults2(dst, AVMEDIA_TYPE_VIDEO);
|
||||
#endif
|
||||
|
||||
if (dst_fmt->flags & AVFMT_GLOBALHEADER)
|
||||
@@ -262,7 +270,7 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma
|
||||
dst->width = out_w;
|
||||
dst->height = out_h;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR <= 52 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR <= 1)
|
||||
#if LIBAVFORMAT_VERSION_MAJOR <= 52 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR <= 1)
|
||||
ret = av_set_parameters(dst_ctx, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -274,7 +282,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma
|
||||
#endif
|
||||
|
||||
/* Open encoder */
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 54 || (LIBAVCODEC_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 6)
|
||||
ret = avcodec_open2(dst, img_encoder, NULL);
|
||||
#else
|
||||
ret = avcodec_open(dst, img_encoder);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Could not open codec for encoding: %s\n", strerror(AVUNERROR(ret)));
|
||||
@@ -410,7 +422,7 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma
|
||||
pkt.data = outbuf;
|
||||
pkt.size = ret;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3)
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3)
|
||||
ret = avformat_write_header(dst_ctx, NULL);
|
||||
#else
|
||||
ret = av_write_header(dst_ctx);
|
||||
@@ -505,7 +517,7 @@ artwork_get(char *filename, int max_w, int max_h, int format, struct evbuffer *e
|
||||
|
||||
src_ctx = NULL;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3)
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3)
|
||||
ret = avformat_open_input(&src_ctx, filename, NULL, NULL);
|
||||
#else
|
||||
ret = av_open_input_file(&src_ctx, filename, NULL, 0, NULL);
|
||||
@@ -517,12 +529,20 @@ artwork_get(char *filename, int max_w, int max_h, int format, struct evbuffer *e
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3)
|
||||
ret = avformat_find_stream_info(src_ctx, NULL);
|
||||
#else
|
||||
ret = av_find_stream_info(src_ctx);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_WARN, L_ART, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret)));
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 21)
|
||||
avformat_close_input(&src_ctx);
|
||||
#else
|
||||
av_close_input_file(src_ctx);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -545,7 +565,11 @@ artwork_get(char *filename, int max_w, int max_h, int format, struct evbuffer *e
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Artwork file '%s' not a PNG or JPEG file\n", filename);
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 21)
|
||||
avformat_close_input(&src_ctx);
|
||||
#else
|
||||
av_close_input_file(src_ctx);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -602,7 +626,11 @@ artwork_get(char *filename, int max_w, int max_h, int format, struct evbuffer *e
|
||||
else
|
||||
ret = artwork_rescale(src_ctx, s, target_w, target_h, format, evbuf);
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 21)
|
||||
avformat_close_input(&src_ctx);
|
||||
#else
|
||||
av_close_input_file(src_ctx);
|
||||
#endif
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user