You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
avcodec/decode: Optimize lcevc away if disabled
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -47,7 +47,6 @@ OBJS = ac3_parser.o \
|
|||||||
get_buffer.o \
|
get_buffer.o \
|
||||||
imgconvert.o \
|
imgconvert.o \
|
||||||
jni.o \
|
jni.o \
|
||||||
lcevcdec.o \
|
|
||||||
mathtables.o \
|
mathtables.o \
|
||||||
mediacodec.o \
|
mediacodec.o \
|
||||||
mpeg12framerate.o \
|
mpeg12framerate.o \
|
||||||
@@ -130,6 +129,7 @@ OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o
|
|||||||
OBJS-$(CONFIG_JNI) += ffjni.o jni.o
|
OBJS-$(CONFIG_JNI) += ffjni.o jni.o
|
||||||
OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o
|
OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o
|
||||||
OBJS-$(CONFIG_LCMS2) += fflcms2.o
|
OBJS-$(CONFIG_LCMS2) += fflcms2.o
|
||||||
|
OBJS-$(CONFIG_LIBLCEVC_DEC) += lcevcdec.o
|
||||||
OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o
|
OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o
|
||||||
OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o
|
OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o
|
||||||
OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o
|
OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o
|
||||||
|
|||||||
@@ -94,12 +94,14 @@ typedef struct DecodeContext {
|
|||||||
*/
|
*/
|
||||||
uint64_t side_data_pref_mask;
|
uint64_t side_data_pref_mask;
|
||||||
|
|
||||||
|
#if CONFIG_LIBLCEVC_DEC
|
||||||
struct {
|
struct {
|
||||||
FFLCEVCContext *ctx;
|
FFLCEVCContext *ctx;
|
||||||
int frame;
|
int frame;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
} lcevc;
|
} lcevc;
|
||||||
|
#endif
|
||||||
} DecodeContext;
|
} DecodeContext;
|
||||||
|
|
||||||
static DecodeContext *decode_ctx(AVCodecInternal *avci)
|
static DecodeContext *decode_ctx(AVCodecInternal *avci)
|
||||||
@@ -1660,6 +1662,7 @@ int ff_attach_decode_data(AVFrame *frame)
|
|||||||
|
|
||||||
static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
|
static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
|
||||||
{
|
{
|
||||||
|
#if CONFIG_LIBLCEVC_DEC
|
||||||
AVCodecInternal *avci = avctx->internal;
|
AVCodecInternal *avci = avctx->internal;
|
||||||
DecodeContext *dc = decode_ctx(avci);
|
DecodeContext *dc = decode_ctx(avci);
|
||||||
|
|
||||||
@@ -1672,10 +1675,12 @@ static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
|
|||||||
frame->width = frame->width * 2 / FFMAX(frame->sample_aspect_ratio.den, 1);
|
frame->width = frame->width * 2 / FFMAX(frame->sample_aspect_ratio.den, 1);
|
||||||
frame->height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1);
|
frame->height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
|
static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
|
||||||
{
|
{
|
||||||
|
#if CONFIG_LIBLCEVC_DEC
|
||||||
AVCodecInternal *avci = avctx->internal;
|
AVCodecInternal *avci = avctx->internal;
|
||||||
DecodeContext *dc = decode_ctx(avci);
|
DecodeContext *dc = decode_ctx(avci);
|
||||||
|
|
||||||
@@ -1715,6 +1720,7 @@ static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
|
|||||||
fdd->post_process = ff_lcevc_process;
|
fdd->post_process = ff_lcevc_process;
|
||||||
}
|
}
|
||||||
dc->lcevc.frame = 0;
|
dc->lcevc.frame = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2083,9 +2089,11 @@ av_cold int ff_decode_preinit(AVCodecContext *avctx)
|
|||||||
|
|
||||||
if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
|
if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
|
||||||
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
|
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
#if CONFIG_LIBLCEVC_DEC
|
||||||
ret = ff_lcevc_alloc(&dc->lcevc.ctx);
|
ret = ff_lcevc_alloc(&dc->lcevc.ctx);
|
||||||
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
|
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
|
||||||
return ret;
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2326,15 +2334,19 @@ av_cold void ff_decode_internal_sync(AVCodecContext *dst, const AVCodecContext *
|
|||||||
|
|
||||||
dst_dc->initial_pict_type = src_dc->initial_pict_type;
|
dst_dc->initial_pict_type = src_dc->initial_pict_type;
|
||||||
dst_dc->intra_only_flag = src_dc->intra_only_flag;
|
dst_dc->intra_only_flag = src_dc->intra_only_flag;
|
||||||
|
#if CONFIG_LIBLCEVC_DEC
|
||||||
av_refstruct_replace(&dst_dc->lcevc.ctx, src_dc->lcevc.ctx);
|
av_refstruct_replace(&dst_dc->lcevc.ctx, src_dc->lcevc.ctx);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold void ff_decode_internal_uninit(AVCodecContext *avctx)
|
av_cold void ff_decode_internal_uninit(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
|
#if CONFIG_LIBLCEVC_DEC
|
||||||
AVCodecInternal *avci = avctx->internal;
|
AVCodecInternal *avci = avctx->internal;
|
||||||
DecodeContext *dc = decode_ctx(avci);
|
DecodeContext *dc = decode_ctx(avci);
|
||||||
|
|
||||||
av_refstruct_unref(&dc->lcevc.ctx);
|
av_refstruct_unref(&dc->lcevc.ctx);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int attach_displaymatrix(AVCodecContext *avctx, AVFrame *frame, int orientation)
|
static int attach_displaymatrix(AVCodecContext *avctx, AVFrame *frame, int orientation)
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config_components.h"
|
|
||||||
|
|
||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/frame.h"
|
#include "libavutil/frame.h"
|
||||||
#include "libavutil/imgutils.h"
|
#include "libavutil/imgutils.h"
|
||||||
@@ -28,7 +26,6 @@
|
|||||||
#include "decode.h"
|
#include "decode.h"
|
||||||
#include "lcevcdec.h"
|
#include "lcevcdec.h"
|
||||||
|
|
||||||
#if CONFIG_LIBLCEVC_DEC
|
|
||||||
static LCEVC_ColorFormat map_format(int format)
|
static LCEVC_ColorFormat map_format(int format)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
@@ -249,11 +246,9 @@ static void lcevc_free(AVRefStructOpaque unused, void *obj)
|
|||||||
LCEVC_DestroyDecoder(lcevc->decoder);
|
LCEVC_DestroyDecoder(lcevc->decoder);
|
||||||
memset(lcevc, 0, sizeof(*lcevc));
|
memset(lcevc, 0, sizeof(*lcevc));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int lcevc_init(FFLCEVCContext *lcevc, void *logctx)
|
static int lcevc_init(FFLCEVCContext *lcevc, void *logctx)
|
||||||
{
|
{
|
||||||
#if CONFIG_LIBLCEVC_DEC
|
|
||||||
LCEVC_AccelContextHandle dummy = { 0 };
|
LCEVC_AccelContextHandle dummy = { 0 };
|
||||||
const int32_t event = LCEVC_Log;
|
const int32_t event = LCEVC_Log;
|
||||||
|
|
||||||
@@ -272,7 +267,6 @@ static int lcevc_init(FFLCEVCContext *lcevc, void *logctx)
|
|||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
lcevc->initialized = 1;
|
lcevc->initialized = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -291,7 +285,6 @@ int ff_lcevc_process(void *logctx, AVFrame *frame)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_LIBLCEVC_DEC
|
|
||||||
av_assert0(frame_ctx->frame);
|
av_assert0(frame_ctx->frame);
|
||||||
|
|
||||||
|
|
||||||
@@ -304,7 +297,6 @@ int ff_lcevc_process(void *logctx, AVFrame *frame)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
av_frame_remove_side_data(frame, AV_FRAME_DATA_LCEVC);
|
av_frame_remove_side_data(frame, AV_FRAME_DATA_LCEVC);
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -312,11 +304,9 @@ int ff_lcevc_process(void *logctx, AVFrame *frame)
|
|||||||
int ff_lcevc_alloc(FFLCEVCContext **plcevc)
|
int ff_lcevc_alloc(FFLCEVCContext **plcevc)
|
||||||
{
|
{
|
||||||
FFLCEVCContext *lcevc = NULL;
|
FFLCEVCContext *lcevc = NULL;
|
||||||
#if CONFIG_LIBLCEVC_DEC
|
|
||||||
lcevc = av_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free);
|
lcevc = av_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free);
|
||||||
if (!lcevc)
|
if (!lcevc)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
#endif
|
|
||||||
*plcevc = lcevc;
|
*plcevc = lcevc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user