mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge commit 'be00ec832c519427cd92218abac77dafdc1d5487'
* commit 'be00ec832c519427cd92218abac77dafdc1d5487': lavc: Deprecate coder_type and its symbols Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
commit
2630f7f709
@ -2561,6 +2561,7 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
int rc_initial_buffer_occupancy;
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
#define FF_CODER_TYPE_VLC 0
|
||||
#define FF_CODER_TYPE_AC 1
|
||||
#define FF_CODER_TYPE_RAW 2
|
||||
@ -2569,11 +2570,11 @@ typedef struct AVCodecContext {
|
||||
#define FF_CODER_TYPE_DEFLATE 4
|
||||
#endif /* FF_API_UNUSED_MEMBERS */
|
||||
/**
|
||||
* coder type
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
* @deprecated use encoder private options instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
int coder_type;
|
||||
#endif /* FF_API_CODER_TYPE */
|
||||
|
||||
/**
|
||||
* context model
|
||||
|
@ -700,7 +700,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (avctx->coder_type != -1)
|
||||
s->ac = avctx->coder_type > 0 ? AC_RANGE_CUSTOM_TAB : AC_GOLOMB_RICE;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
s->plane_count = 3;
|
||||
switch(avctx->pix_fmt) {
|
||||
@ -1346,6 +1351,15 @@ static av_cold int encode_close(AVCodecContext *avctx)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "slicecrc", "Protect slices with CRCs", OFFSET(ec), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE },
|
||||
{ "coder", "Coder type", OFFSET(ac), AV_OPT_TYPE_INT,
|
||||
{ .i64 = AC_GOLOMB_RICE }, 0, 2, VE, "coder" },
|
||||
{ "rice", "Golomb rice", 0, AV_OPT_TYPE_CONST,
|
||||
{ .i64 = AC_GOLOMB_RICE }, INT_MIN, INT_MAX, VE, "coder" },
|
||||
{ "range_def", "Range with default table", 0, AV_OPT_TYPE_CONST,
|
||||
{ .i64 = AC_RANGE_DEFAULT_TAB }, INT_MIN, INT_MAX, VE, "coder" },
|
||||
{ "range_tab", "Range with custom table", 0, AV_OPT_TYPE_CONST,
|
||||
{ .i64 = AC_RANGE_CUSTOM_TAB }, INT_MIN, INT_MAX, VE, "coder" },
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -1356,10 +1370,12 @@ static const AVClass ffv1_class = {
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
static const AVCodecDefault ffv1_defaults[] = {
|
||||
{ "coder", "-1" },
|
||||
{ NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
AVCodec ff_ffv1_encoder = {
|
||||
.name = "ffv1",
|
||||
@ -1385,6 +1401,8 @@ AVCodec ff_ffv1_encoder = {
|
||||
AV_PIX_FMT_NONE
|
||||
|
||||
},
|
||||
#if FF_API_CODER_TYPE
|
||||
.defaults = ffv1_defaults,
|
||||
#endif
|
||||
.priv_class = &ffv1_class,
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ typedef struct SVCContext {
|
||||
int max_nal_size;
|
||||
int skip_frames;
|
||||
int skipped;
|
||||
int cabac;
|
||||
} SVCContext;
|
||||
|
||||
#define OPENH264_VER_AT_LEAST(maj, min) \
|
||||
@ -58,6 +59,7 @@ static const AVOption options[] = {
|
||||
{ "profile", "set profile restrictions", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
|
||||
{ "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
|
||||
{ "allow_skip_frames", "allow skipping frames to hit the target bitrate", OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||
{ "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -139,6 +141,13 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
|
||||
|
||||
(*s->encoder)->GetDefaultParams(s->encoder, ¶m);
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (!s->cabac)
|
||||
s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
param.fMaxFrameRate = 1/av_q2d(avctx->time_base);
|
||||
param.iPicWidth = avctx->width;
|
||||
param.iPicHeight = avctx->height;
|
||||
@ -165,7 +174,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
|
||||
param.iMultipleThreadIdc = avctx->thread_count;
|
||||
if (s->profile && !strcmp(s->profile, "main"))
|
||||
param.iEntropyCodingModeFlag = 1;
|
||||
else if (!s->profile && avctx->coder_type == FF_CODER_TYPE_AC)
|
||||
else if (!s->profile && s->cabac)
|
||||
param.iEntropyCodingModeFlag = 1;
|
||||
|
||||
param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
@ -72,6 +73,9 @@ typedef struct SchroEncoderParams {
|
||||
|
||||
/* counter for frames submitted to encoder, used as dts */
|
||||
int64_t dts;
|
||||
|
||||
/** enable noarith */
|
||||
int noarith;
|
||||
} SchroEncoderParams;
|
||||
|
||||
/**
|
||||
@ -166,9 +170,15 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
|
||||
"gop_structure",
|
||||
SCHRO_ENCODER_GOP_INTRA_ONLY);
|
||||
|
||||
if (avctx->coder_type == FF_CODER_TYPE_VLC)
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (avctx->coder_type != FF_CODER_TYPE_VLC)
|
||||
p_schro_params->noarith = 0;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
schro_encoder_setting_set_double(p_schro_params->encoder,
|
||||
"enable_noarith", 1);
|
||||
"enable_noarith",
|
||||
p_schro_params->noarith);
|
||||
} else {
|
||||
schro_encoder_setting_set_double(p_schro_params->encoder,
|
||||
"au_distance", avctx->gop_size);
|
||||
@ -441,6 +451,20 @@ static int libschroedinger_encode_close(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(SchroEncoderParams, x)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "noarith", "Enable noarith", OFFSET(noarith), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass libschroedinger_class = {
|
||||
.class_name = "libschroedinger",
|
||||
.item_name = av_default_item_name,
|
||||
.option = options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
AVCodec ff_libschroedinger_encoder = {
|
||||
.name = "libschroedinger",
|
||||
@ -448,6 +472,7 @@ AVCodec ff_libschroedinger_encoder = {
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_DIRAC,
|
||||
.priv_data_size = sizeof(SchroEncoderParams),
|
||||
.priv_class = &libschroedinger_class,
|
||||
.init = libschroedinger_encode_init,
|
||||
.encode2 = libschroedinger_encode_frame,
|
||||
.close = libschroedinger_encode_close,
|
||||
|
@ -84,7 +84,9 @@ typedef struct X264Context {
|
||||
int avcintra_class;
|
||||
int motion_est;
|
||||
int forced_idr;
|
||||
int coder;
|
||||
int a53_cc;
|
||||
|
||||
char *x264_params;
|
||||
} X264Context;
|
||||
|
||||
@ -582,8 +584,12 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
||||
x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
|
||||
if (avctx->keyint_min >= 0)
|
||||
x4->params.i_keyint_min = avctx->keyint_min;
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (avctx->coder_type >= 0)
|
||||
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
|
||||
x4->coder = avctx->coder_type == FF_CODER_TYPE_AC;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
if (avctx->me_cmp >= 0)
|
||||
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
|
||||
|
||||
@ -701,6 +707,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
}
|
||||
|
||||
if (x4->coder >= 0)
|
||||
x4->params.b_cabac = x4->coder;
|
||||
|
||||
if (x4->profile)
|
||||
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
|
||||
int i;
|
||||
@ -940,6 +949,11 @@ static const AVOption options[] = {
|
||||
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
|
||||
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
|
||||
{ "forced-idr", "If forcing keyframes, force them as IDR frames.", OFFSET(forced_idr), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE },
|
||||
{ "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, "coder" },
|
||||
{ "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, VE, "coder" },
|
||||
{ "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "coder" },
|
||||
{ "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "coder" },
|
||||
|
||||
{ "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
|
||||
{ NULL },
|
||||
};
|
||||
@ -968,7 +982,9 @@ static const AVCodecDefault x264_defaults[] = {
|
||||
{ "subq", "-1" },
|
||||
{ "b_strategy", "-1" },
|
||||
{ "keyint_min", "-1" },
|
||||
#if FF_API_CODER_TYPE
|
||||
{ "coder", "-1" },
|
||||
#endif
|
||||
{ "cmp", "-1" },
|
||||
{ "threads", AV_STRINGIFY(X264_THREADS_AUTO) },
|
||||
{ "thread_type", "0" },
|
||||
|
@ -311,6 +311,7 @@ static const AVOption avcodec_options[] = {
|
||||
{"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
|
||||
#endif
|
||||
{"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
|
||||
#if FF_API_CODER_TYPE
|
||||
{"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"},
|
||||
{"vlc", "variable length coder / Huffman coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"},
|
||||
{"ac", "arithmetic coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_AC }, INT_MIN, INT_MAX, V|E, "coder"},
|
||||
@ -319,6 +320,7 @@ static const AVOption avcodec_options[] = {
|
||||
#if FF_API_UNUSED_MEMBERS
|
||||
{"deflate", "deflate-based coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"},
|
||||
#endif /* FF_API_UNUSED_MEMBERS */
|
||||
#endif /* FF_API_CODER_TYPE */
|
||||
{"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
|
||||
{"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
|
||||
#if FF_API_XVMC
|
||||
|
@ -19,6 +19,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
#include "internal.h"
|
||||
@ -28,6 +30,12 @@
|
||||
#define SGI_SINGLE_CHAN 2
|
||||
#define SGI_MULTI_CHAN 3
|
||||
|
||||
typedef struct SgiContext {
|
||||
AVClass *class;
|
||||
|
||||
int rle;
|
||||
} SgiContext;
|
||||
|
||||
static av_cold int encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
if (avctx->width > 65535 || avctx->height > 65535) {
|
||||
@ -84,6 +92,7 @@ static int sgi_rle_encode(PutByteContext *pbc, const uint8_t *src,
|
||||
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
const AVFrame *frame, int *got_packet)
|
||||
{
|
||||
SgiContext *s = avctx->priv_data;
|
||||
const AVFrame * const p = frame;
|
||||
PutByteContext pbc;
|
||||
uint8_t *in_buf, *encode_buf;
|
||||
@ -96,6 +105,13 @@ FF_DISABLE_DEPRECATION_WARNINGS
|
||||
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||
avctx->coded_frame->key_frame = 1;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (avctx->coder_type == FF_CODER_TYPE_RAW)
|
||||
s->rle = 0;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
width = avctx->width;
|
||||
@ -147,7 +163,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
tablesize = depth * height * 4;
|
||||
length = SGI_HEADER_SIZE;
|
||||
if (avctx->coder_type == FF_CODER_TYPE_RAW)
|
||||
if (!s->rle)
|
||||
length += depth * height * width;
|
||||
else // assume sgi_rle_encode() produces at most 2x size of input
|
||||
length += tablesize * 2 + depth * height * (2 * width + 1);
|
||||
@ -159,7 +175,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
/* Encode header. */
|
||||
bytestream2_put_be16(&pbc, SGI_MAGIC);
|
||||
bytestream2_put_byte(&pbc, avctx->coder_type != FF_CODER_TYPE_RAW); /* RLE 1 - VERBATIM 0 */
|
||||
bytestream2_put_byte(&pbc, s->rle); /* RLE 1 - VERBATIM 0 */
|
||||
bytestream2_put_byte(&pbc, bytes_per_channel);
|
||||
bytestream2_put_be16(&pbc, dimension);
|
||||
bytestream2_put_be16(&pbc, width);
|
||||
@ -179,7 +195,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
/* The rest of the 512 byte header is unused. */
|
||||
bytestream2_skip_p(&pbc, 404);
|
||||
|
||||
if (avctx->coder_type != FF_CODER_TYPE_RAW) {
|
||||
if (s->rle) {
|
||||
PutByteContext taboff_pcb, tablen_pcb;
|
||||
|
||||
/* Skip RLE offset table. */
|
||||
@ -243,11 +259,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(SgiContext, x)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "rle", "Use run-length compression", OFFSET(rle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass sgi_class = {
|
||||
.class_name = "sgi",
|
||||
.item_name = av_default_item_name,
|
||||
.option = options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
AVCodec ff_sgi_encoder = {
|
||||
.name = "sgi",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("SGI image"),
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_SGI,
|
||||
.priv_data_size = sizeof(SgiContext),
|
||||
.priv_class = &sgi_class,
|
||||
.init = encode_init,
|
||||
.encode2 = encode_frame,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
|
@ -19,6 +19,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
#include "internal.h"
|
||||
@ -136,6 +138,8 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
SUNRASTContext *s = avctx->priv_data;
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
switch (avctx->coder_type) {
|
||||
case FF_CODER_TYPE_RLE:
|
||||
s->type = RT_BYTE_ENCODED;
|
||||
@ -147,6 +151,11 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
if (s->type != RT_BYTE_ENCODED && s->type != RT_STANDARD)
|
||||
#endif
|
||||
// adjust boolean option to RT equivalent
|
||||
s->type++;
|
||||
|
||||
s->maptype = RMT_NONE;
|
||||
s->maplength = 0;
|
||||
@ -169,8 +178,7 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);
|
||||
s->size = 32 + s->maplength +
|
||||
s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);
|
||||
s->size = 32 + s->maplength + s->length * s->type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -199,10 +207,27 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(SUNRASTContext, x)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "rle", "Use run-length compression", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass utvideo_class = {
|
||||
.class_name = "sunrast",
|
||||
.item_name = av_default_item_name,
|
||||
.option = options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
static const AVCodecDefault sunrast_defaults[] = {
|
||||
{ "coder", "rle" },
|
||||
{ NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
AVCodec ff_sunrast_encoder = {
|
||||
.name = "sunrast",
|
||||
@ -212,7 +237,9 @@ AVCodec ff_sunrast_encoder = {
|
||||
.priv_data_size = sizeof(SUNRASTContext),
|
||||
.init = sunrast_encode_init,
|
||||
.encode2 = sunrast_encode_frame,
|
||||
#if FF_API_CODER_TYPE
|
||||
.defaults = sunrast_defaults,
|
||||
#endif
|
||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24,
|
||||
AV_PIX_FMT_PAL8,
|
||||
AV_PIX_FMT_GRAY8,
|
||||
|
@ -24,12 +24,19 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "rle.h"
|
||||
#include "targa.h"
|
||||
|
||||
typedef struct TargaContext {
|
||||
AVClass *class;
|
||||
|
||||
int rle;
|
||||
} TargaContext;
|
||||
|
||||
/**
|
||||
* RLE compress the image, with maximum size of out_size
|
||||
* @param outbuf Output buffer
|
||||
@ -78,6 +85,7 @@ static int targa_encode_normal(uint8_t *outbuf, const AVFrame *pic, int bpp, int
|
||||
static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
const AVFrame *p, int *got_packet)
|
||||
{
|
||||
TargaContext *s = avctx->priv_data;
|
||||
int bpp, picsize, datasize = -1, ret, i;
|
||||
uint8_t *out;
|
||||
|
||||
@ -147,8 +155,16 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
}
|
||||
bpp = pkt->data[16] >> 3;
|
||||
|
||||
|
||||
#if FF_API_CODER_TYPE
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (avctx->coder_type == FF_CODER_TYPE_RAW)
|
||||
s->rle = 0;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
/* try RLE compression */
|
||||
if (avctx->coder_type != FF_CODER_TYPE_RAW)
|
||||
if (s->rle)
|
||||
datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
|
||||
|
||||
/* if that worked well, mark the picture as RLE compressed */
|
||||
@ -184,11 +200,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(TargaContext, x)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "rle", "Use run-length compression", OFFSET(rle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass targa_class = {
|
||||
.class_name = "targa",
|
||||
.item_name = av_default_item_name,
|
||||
.option = options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
AVCodec ff_targa_encoder = {
|
||||
.name = "targa",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_TARGA,
|
||||
.priv_data_size = sizeof(TargaContext),
|
||||
.priv_class = &targa_class,
|
||||
.init = targa_encode_init,
|
||||
.encode2 = targa_encode_frame,
|
||||
.pix_fmts = (const enum AVPixelFormat[]){
|
||||
|
@ -200,5 +200,8 @@
|
||||
#ifndef FF_API_VBV_DELAY
|
||||
#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
#ifndef FF_API_CODER_TYPE
|
||||
#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59)
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_VERSION_H */
|
||||
|
Loading…
Reference in New Issue
Block a user