Commit 2630f7f7 authored by Hendrik Leppkes's avatar Hendrik Leppkes

Merge commit 'be00ec83'

* commit 'be00ec83':
  lavc: Deprecate coder_type and its symbols
Merged-by: 's avatarHendrik Leppkes <h.leppkes@gmail.com>
parents ec1b95dd be00ec83
...@@ -2561,6 +2561,7 @@ typedef struct AVCodecContext { ...@@ -2561,6 +2561,7 @@ typedef struct AVCodecContext {
*/ */
int rc_initial_buffer_occupancy; int rc_initial_buffer_occupancy;
#if FF_API_CODER_TYPE
#define FF_CODER_TYPE_VLC 0 #define FF_CODER_TYPE_VLC 0
#define FF_CODER_TYPE_AC 1 #define FF_CODER_TYPE_AC 1
#define FF_CODER_TYPE_RAW 2 #define FF_CODER_TYPE_RAW 2
...@@ -2569,11 +2570,11 @@ typedef struct AVCodecContext { ...@@ -2569,11 +2570,11 @@ typedef struct AVCodecContext {
#define FF_CODER_TYPE_DEFLATE 4 #define FF_CODER_TYPE_DEFLATE 4
#endif /* FF_API_UNUSED_MEMBERS */ #endif /* FF_API_UNUSED_MEMBERS */
/** /**
* coder type * @deprecated use encoder private options instead
* - encoding: Set by user.
* - decoding: unused
*/ */
attribute_deprecated
int coder_type; int coder_type;
#endif /* FF_API_CODER_TYPE */
/** /**
* context model * context model
......
...@@ -700,7 +700,12 @@ static av_cold int encode_init(AVCodecContext *avctx) ...@@ -700,7 +700,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
s->ac = avctx->coder_type > 0 ? AC_RANGE_CUSTOM_TAB : AC_GOLOMB_RICE; #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; s->plane_count = 3;
switch(avctx->pix_fmt) { switch(avctx->pix_fmt) {
...@@ -1346,6 +1351,15 @@ static av_cold int encode_close(AVCodecContext *avctx) ...@@ -1346,6 +1351,15 @@ static av_cold int encode_close(AVCodecContext *avctx)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = { static const AVOption options[] = {
{ "slicecrc", "Protect slices with CRCs", OFFSET(ec), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE }, { "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 } { NULL }
}; };
...@@ -1356,10 +1370,12 @@ static const AVClass ffv1_class = { ...@@ -1356,10 +1370,12 @@ static const AVClass ffv1_class = {
.version = LIBAVUTIL_VERSION_INT, .version = LIBAVUTIL_VERSION_INT,
}; };
#if FF_API_CODER_TYPE
static const AVCodecDefault ffv1_defaults[] = { static const AVCodecDefault ffv1_defaults[] = {
{ "coder", "-1" }, { "coder", "-1" },
{ NULL }, { NULL },
}; };
#endif
AVCodec ff_ffv1_encoder = { AVCodec ff_ffv1_encoder = {
.name = "ffv1", .name = "ffv1",
...@@ -1385,6 +1401,8 @@ AVCodec ff_ffv1_encoder = { ...@@ -1385,6 +1401,8 @@ AVCodec ff_ffv1_encoder = {
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}, },
#if FF_API_CODER_TYPE
.defaults = ffv1_defaults, .defaults = ffv1_defaults,
#endif
.priv_class = &ffv1_class, .priv_class = &ffv1_class,
}; };
...@@ -40,6 +40,7 @@ typedef struct SVCContext { ...@@ -40,6 +40,7 @@ typedef struct SVCContext {
int max_nal_size; int max_nal_size;
int skip_frames; int skip_frames;
int skipped; int skipped;
int cabac;
} SVCContext; } SVCContext;
#define OPENH264_VER_AT_LEAST(maj, min) \ #define OPENH264_VER_AT_LEAST(maj, min) \
...@@ -58,6 +59,7 @@ static const AVOption options[] = { ...@@ -58,6 +59,7 @@ static const AVOption options[] = {
{ "profile", "set profile restrictions", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, { "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 }, { "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 }, { "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 } { NULL }
}; };
...@@ -139,6 +141,13 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) ...@@ -139,6 +141,13 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
(*s->encoder)->GetDefaultParams(s->encoder, &param); (*s->encoder)->GetDefaultParams(s->encoder, &param);
#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.fMaxFrameRate = 1/av_q2d(avctx->time_base);
param.iPicWidth = avctx->width; param.iPicWidth = avctx->width;
param.iPicHeight = avctx->height; param.iPicHeight = avctx->height;
...@@ -165,7 +174,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) ...@@ -165,7 +174,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
param.iMultipleThreadIdc = avctx->thread_count; param.iMultipleThreadIdc = avctx->thread_count;
if (s->profile && !strcmp(s->profile, "main")) if (s->profile && !strcmp(s->profile, "main"))
param.iEntropyCodingModeFlag = 1; param.iEntropyCodingModeFlag = 1;
else if (!s->profile && avctx->coder_type == FF_CODER_TYPE_AC) else if (!s->profile && s->cabac)
param.iEntropyCodingModeFlag = 1; param.iEntropyCodingModeFlag = 1;
param.sSpatialLayers[0].iVideoWidth = param.iPicWidth; param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#include "libavutil/avassert.h" #include "libavutil/avassert.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "avcodec.h" #include "avcodec.h"
#include "internal.h" #include "internal.h"
...@@ -72,6 +73,9 @@ typedef struct SchroEncoderParams { ...@@ -72,6 +73,9 @@ typedef struct SchroEncoderParams {
/* counter for frames submitted to encoder, used as dts */ /* counter for frames submitted to encoder, used as dts */
int64_t dts; int64_t dts;
/** enable noarith */
int noarith;
} SchroEncoderParams; } SchroEncoderParams;
/** /**
...@@ -166,9 +170,15 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx) ...@@ -166,9 +170,15 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
"gop_structure", "gop_structure",
SCHRO_ENCODER_GOP_INTRA_ONLY); SCHRO_ENCODER_GOP_INTRA_ONLY);
if (avctx->coder_type == FF_CODER_TYPE_VLC) #if FF_API_CODER_TYPE
schro_encoder_setting_set_double(p_schro_params->encoder, FF_DISABLE_DEPRECATION_WARNINGS
"enable_noarith", 1); 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",
p_schro_params->noarith);
} else { } else {
schro_encoder_setting_set_double(p_schro_params->encoder, schro_encoder_setting_set_double(p_schro_params->encoder,
"au_distance", avctx->gop_size); "au_distance", avctx->gop_size);
...@@ -441,6 +451,20 @@ static int libschroedinger_encode_close(AVCodecContext *avctx) ...@@ -441,6 +451,20 @@ static int libschroedinger_encode_close(AVCodecContext *avctx)
return 0; 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 = { AVCodec ff_libschroedinger_encoder = {
.name = "libschroedinger", .name = "libschroedinger",
...@@ -448,6 +472,7 @@ AVCodec ff_libschroedinger_encoder = { ...@@ -448,6 +472,7 @@ AVCodec ff_libschroedinger_encoder = {
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_DIRAC, .id = AV_CODEC_ID_DIRAC,
.priv_data_size = sizeof(SchroEncoderParams), .priv_data_size = sizeof(SchroEncoderParams),
.priv_class = &libschroedinger_class,
.init = libschroedinger_encode_init, .init = libschroedinger_encode_init,
.encode2 = libschroedinger_encode_frame, .encode2 = libschroedinger_encode_frame,
.close = libschroedinger_encode_close, .close = libschroedinger_encode_close,
......
...@@ -84,7 +84,9 @@ typedef struct X264Context { ...@@ -84,7 +84,9 @@ typedef struct X264Context {
int avcintra_class; int avcintra_class;
int motion_est; int motion_est;
int forced_idr; int forced_idr;
int coder;
int a53_cc; int a53_cc;
char *x264_params; char *x264_params;
} X264Context; } X264Context;
...@@ -582,8 +584,12 @@ static av_cold int X264_init(AVCodecContext *avctx) ...@@ -582,8 +584,12 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.i_bframe_adaptive = avctx->b_frame_strategy; x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
if (avctx->keyint_min >= 0) if (avctx->keyint_min >= 0)
x4->params.i_keyint_min = avctx->keyint_min; x4->params.i_keyint_min = avctx->keyint_min;
#if FF_API_CODER_TYPE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->coder_type >= 0) 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) if (avctx->me_cmp >= 0)
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
...@@ -701,6 +707,9 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -701,6 +707,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
} }
if (x4->coder >= 0)
x4->params.b_cabac = x4->coder;
if (x4->profile) if (x4->profile)
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) { if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
int i; int i;
...@@ -940,6 +949,11 @@ static const AVOption options[] = { ...@@ -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" }, { "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" }, { "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 }, { "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 }, { "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 }, { NULL },
}; };
...@@ -968,7 +982,9 @@ static const AVCodecDefault x264_defaults[] = { ...@@ -968,7 +982,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "subq", "-1" }, { "subq", "-1" },
{ "b_strategy", "-1" }, { "b_strategy", "-1" },
{ "keyint_min", "-1" }, { "keyint_min", "-1" },
#if FF_API_CODER_TYPE
{ "coder", "-1" }, { "coder", "-1" },
#endif
{ "cmp", "-1" }, { "cmp", "-1" },
{ "threads", AV_STRINGIFY(X264_THREADS_AUTO) }, { "threads", AV_STRINGIFY(X264_THREADS_AUTO) },
{ "thread_type", "0" }, { "thread_type", "0" },
......
...@@ -311,6 +311,7 @@ static const AVOption avcodec_options[] = { ...@@ -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}, {"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
#endif #endif
{"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, {"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"}, {"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"}, {"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"}, {"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[] = { ...@@ -319,6 +320,7 @@ static const AVOption avcodec_options[] = {
#if FF_API_UNUSED_MEMBERS #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"}, {"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_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}, {"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}, {"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#if FF_API_XVMC #if FF_API_XVMC
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* 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 "libavutil/opt.h"
#include "avcodec.h" #include "avcodec.h"
#include "bytestream.h" #include "bytestream.h"
#include "internal.h" #include "internal.h"
...@@ -28,6 +30,12 @@ ...@@ -28,6 +30,12 @@
#define SGI_SINGLE_CHAN 2 #define SGI_SINGLE_CHAN 2
#define SGI_MULTI_CHAN 3 #define SGI_MULTI_CHAN 3
typedef struct SgiContext {
AVClass *class;
int rle;
} SgiContext;
static av_cold int encode_init(AVCodecContext *avctx) static av_cold int encode_init(AVCodecContext *avctx)
{ {
if (avctx->width > 65535 || avctx->height > 65535) { if (avctx->width > 65535 || avctx->height > 65535) {
...@@ -84,6 +92,7 @@ static int sgi_rle_encode(PutByteContext *pbc, const uint8_t *src, ...@@ -84,6 +92,7 @@ static int sgi_rle_encode(PutByteContext *pbc, const uint8_t *src,
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet) const AVFrame *frame, int *got_packet)
{ {
SgiContext *s = avctx->priv_data;
const AVFrame * const p = frame; const AVFrame * const p = frame;
PutByteContext pbc; PutByteContext pbc;
uint8_t *in_buf, *encode_buf; uint8_t *in_buf, *encode_buf;
...@@ -96,6 +105,13 @@ FF_DISABLE_DEPRECATION_WARNINGS ...@@ -96,6 +105,13 @@ FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1; avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS 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 #endif
width = avctx->width; width = avctx->width;
...@@ -147,7 +163,7 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -147,7 +163,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
tablesize = depth * height * 4; tablesize = depth * height * 4;
length = SGI_HEADER_SIZE; length = SGI_HEADER_SIZE;
if (avctx->coder_type == FF_CODER_TYPE_RAW) if (!s->rle)
length += depth * height * width; length += depth * height * width;
else // assume sgi_rle_encode() produces at most 2x size of input else // assume sgi_rle_encode() produces at most 2x size of input
length += tablesize * 2 + depth * height * (2 * width + 1); length += tablesize * 2 + depth * height * (2 * width + 1);
...@@ -159,7 +175,7 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -159,7 +175,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* Encode header. */ /* Encode header. */
bytestream2_put_be16(&pbc, SGI_MAGIC); 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_byte(&pbc, bytes_per_channel);
bytestream2_put_be16(&pbc, dimension); bytestream2_put_be16(&pbc, dimension);
bytestream2_put_be16(&pbc, width); bytestream2_put_be16(&pbc, width);
...@@ -179,7 +195,7 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -179,7 +195,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* The rest of the 512 byte header is unused. */ /* The rest of the 512 byte header is unused. */
bytestream2_skip_p(&pbc, 404); bytestream2_skip_p(&pbc, 404);
if (avctx->coder_type != FF_CODER_TYPE_RAW) { if (s->rle) {
PutByteContext taboff_pcb, tablen_pcb; PutByteContext taboff_pcb, tablen_pcb;
/* Skip RLE offset table. */ /* Skip RLE offset table. */
...@@ -243,11 +259,28 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -243,11 +259,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0; 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 = { AVCodec ff_sgi_encoder = {
.name = "sgi", .name = "sgi",
.long_name = NULL_IF_CONFIG_SMALL("SGI image"), .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SGI, .id = AV_CODEC_ID_SGI,
.priv_data_size = sizeof(SgiContext),
.priv_class = &sgi_class,
.init = encode_init, .init = encode_init,
.encode2 = encode_frame, .encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { .pix_fmts = (const enum AVPixelFormat[]) {
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* 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 "libavutil/opt.h"
#include "avcodec.h" #include "avcodec.h"
#include "bytestream.h" #include "bytestream.h"
#include "internal.h" #include "internal.h"
...@@ -136,6 +138,8 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx) ...@@ -136,6 +138,8 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
{ {
SUNRASTContext *s = avctx->priv_data; SUNRASTContext *s = avctx->priv_data;
#if FF_API_CODER_TYPE
FF_DISABLE_DEPRECATION_WARNINGS
switch (avctx->coder_type) { switch (avctx->coder_type) {
case FF_CODER_TYPE_RLE: case FF_CODER_TYPE_RLE:
s->type = RT_BYTE_ENCODED; s->type = RT_BYTE_ENCODED;
...@@ -147,6 +151,11 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx) ...@@ -147,6 +151,11 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n"); av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n");
return AVERROR(EINVAL); 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->maptype = RMT_NONE;
s->maplength = 0; s->maplength = 0;
...@@ -169,8 +178,7 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx) ...@@ -169,8 +178,7 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
return AVERROR_BUG; return AVERROR_BUG;
} }
s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3); s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);
s->size = 32 + s->maplength + s->size = 32 + s->maplength + s->length * s->type;
s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);
return 0; return 0;
} }
...@@ -199,10 +207,27 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -199,10 +207,27 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return 0; 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[] = { static const AVCodecDefault sunrast_defaults[] = {
{ "coder", "rle" }, { "coder", "rle" },
{ NULL }, { NULL },
}; };
#endif
AVCodec ff_sunrast_encoder = { AVCodec ff_sunrast_encoder = {
.name = "sunrast", .name = "sunrast",
...@@ -212,7 +237,9 @@ AVCodec ff_sunrast_encoder = { ...@@ -212,7 +237,9 @@ AVCodec ff_sunrast_encoder = {
.priv_data_size = sizeof(SUNRASTContext), .priv_data_size = sizeof(SUNRASTContext),
.init = sunrast_encode_init, .init = sunrast_encode_init,
.encode2 = sunrast_encode_frame, .encode2 = sunrast_encode_frame,
#if FF_API_CODER_TYPE
.defaults = sunrast_defaults, .defaults = sunrast_defaults,
#endif
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24,
AV_PIX_FMT_PAL8, AV_PIX_FMT_PAL8,
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8,
......
...@@ -24,12 +24,19 @@ ...@@ -24,12 +24,19 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/internal.h" #include "libavutil/internal.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "avcodec.h" #include "avcodec.h"
#include "internal.h" #include "internal.h"
#include "rle.h" #include "rle.h"
#include "targa.h" #include "targa.h"
typedef struct TargaContext {
AVClass *class;
int rle;
} TargaContext;
/** /**
* RLE compress the image, with maximum size of out_size * RLE compress the image, with maximum size of out_size
* @param outbuf Output buffer * @param outbuf Output buffer
...@@ -78,6 +85,7 @@ static int targa_encode_normal(uint8_t *outbuf, const AVFrame *pic, int bpp, int ...@@ -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, static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet) const AVFrame *p, int *got_packet)
{ {
TargaContext *s = avctx->priv_data;
int bpp, picsize, datasize = -1, ret, i; int bpp, picsize, datasize = -1, ret, i;
uint8_t *out; uint8_t *out;
...@@ -147,8 +155,16 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ...@@ -147,8 +155,16 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
bpp = pkt->data[16] >> 3; 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 */ /* 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); datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
/* if that worked well, mark the picture as RLE compressed */ /* if that worked well, mark the picture as RLE compressed */
...@@ -184,11 +200,28 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -184,11 +200,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0; 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 = { AVCodec ff_targa_encoder = {
.name = "targa", .name = "targa",
.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_TARGA, .id = AV_CODEC_ID_TARGA,
.priv_data_size = sizeof(TargaContext),
.priv_class = &targa_class,
.init = targa_encode_init, .init = targa_encode_init,
.encode2 = targa_encode_frame, .encode2 = targa_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){ .pix_fmts = (const enum AVPixelFormat[]){
......
...@@ -200,5 +200,8 @@ ...@@ -200,5 +200,8 @@
#ifndef FF_API_VBV_DELAY #ifndef FF_API_VBV_DELAY
#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59) #define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59)
#endif #endif
#ifndef FF_API_CODER_TYPE
#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment