mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/mpegvideo: Move MJPEG/AMV-only fields to MJpegContext
This is possible now that MJpegContext is allocated jointly with MpegEncContext as part of the AVCodecContext's private data. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
506758357e
commit
bd2ec3d345
|
@ -86,8 +86,10 @@ static void mjpeg_encode_picture_header(MpegEncContext *s)
|
|||
|
||||
void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s)
|
||||
{
|
||||
MJPEGEncContext *const m = (MJPEGEncContext*)s;
|
||||
av_assert2(s->mjpeg_ctx == &m->mjpeg);
|
||||
/* s->huffman == HUFFMAN_TABLE_OPTIMAL can only be true for MJPEG. */
|
||||
if (!CONFIG_MJPEG_ENCODER || s->huffman != HUFFMAN_TABLE_OPTIMAL)
|
||||
if (!CONFIG_MJPEG_ENCODER || m->mjpeg.huffman != HUFFMAN_TABLE_OPTIMAL)
|
||||
mjpeg_encode_picture_header(s);
|
||||
}
|
||||
|
||||
|
@ -211,13 +213,13 @@ static void mjpeg_build_optimal_huffman(MJpegContext *m)
|
|||
*/
|
||||
int ff_mjpeg_encode_stuffing(MpegEncContext *s)
|
||||
{
|
||||
MJpegContext *const m = s->mjpeg_ctx;
|
||||
PutBitContext *pbc = &s->pb;
|
||||
int mb_y = s->mb_y - !s->mb_x;
|
||||
int ret;
|
||||
|
||||
#if CONFIG_MJPEG_ENCODER
|
||||
if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||
MJpegContext *m = s->mjpeg_ctx;
|
||||
if (m->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||
|
||||
mjpeg_build_optimal_huffman(m);
|
||||
|
||||
|
@ -293,7 +295,7 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
|
|||
av_assert0(s->slice_context_count == 1);
|
||||
|
||||
if (s->codec_id == AV_CODEC_ID_AMV || (s->avctx->active_thread_type & FF_THREAD_SLICE))
|
||||
s->huffman = 0;
|
||||
m->huffman = HUFFMAN_TABLE_DEFAULT;
|
||||
|
||||
if (s->mpv_flags & FF_MPV_FLAG_QP_RD) {
|
||||
// Used to produce garbage with MJPEG.
|
||||
|
@ -346,7 +348,7 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
|
|||
// Buffers start out empty.
|
||||
m->huff_ncode = 0;
|
||||
|
||||
if(s->huffman == HUFFMAN_TABLE_OPTIMAL)
|
||||
if (m->huffman == HUFFMAN_TABLE_OPTIMAL)
|
||||
return alloc_huffman(s);
|
||||
|
||||
return 0;
|
||||
|
@ -514,7 +516,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
|
|||
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
|
||||
{
|
||||
int i;
|
||||
if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||
if (s->mjpeg_ctx->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||
if (s->chroma_format == CHROMA_444) {
|
||||
record_block(s, block[0], 0);
|
||||
record_block(s, block[2], 2);
|
||||
|
@ -614,11 +616,11 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
|||
}
|
||||
#endif
|
||||
|
||||
#define OFFSET(x) offsetof(MpegEncContext, x)
|
||||
#define OFFSET(x) offsetof(MJPEGEncContext, mjpeg.x)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
FF_MPV_COMMON_OPTS
|
||||
{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
|
||||
{ "pred", "Prediction method", FF_MPV_OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
|
||||
{ "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
|
||||
{ "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
|
||||
{ "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" },
|
||||
|
|
|
@ -57,6 +57,9 @@ typedef struct MJpegHuffmanCode {
|
|||
* Holds JPEG frame data and Huffman table data.
|
||||
*/
|
||||
typedef struct MJpegContext {
|
||||
int huffman;
|
||||
/* Force duplication of mjpeg matrices, useful for rtp streaming */
|
||||
int force_duplicated_matrix;
|
||||
//FIXME use array [3] instead of lumi / chroma, for easier addressing
|
||||
uint8_t huff_size_dc_luminance[12]; ///< DC luminance Huffman table size.
|
||||
uint16_t huff_code_dc_luminance[12]; ///< DC luminance Huffman table codes.
|
||||
|
|
|
@ -73,7 +73,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
|
|||
int matrix_count = 1 + !!memcmp(luma_intra_matrix,
|
||||
chroma_intra_matrix,
|
||||
sizeof(luma_intra_matrix[0]) * 64);
|
||||
if (s && s->force_duplicated_matrix)
|
||||
if (s && s->mjpeg_ctx->force_duplicated_matrix)
|
||||
matrix_count = 2;
|
||||
/* quant matrixes */
|
||||
put_marker(p, DQT);
|
||||
|
@ -110,7 +110,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
|
|||
|
||||
// Only MJPEG can have a variable Huffman variable. All other
|
||||
// formats use the default Huffman table.
|
||||
if (s && s->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||
if (s && s->mjpeg_ctx->huffman == HUFFMAN_TABLE_OPTIMAL) {
|
||||
size += put_huffman_table(p, 0, 0, s->mjpeg_ctx->bits_dc_luminance,
|
||||
s->mjpeg_ctx->val_dc_luminance);
|
||||
size += put_huffman_table(p, 0, 1, s->mjpeg_ctx->bits_dc_chrominance,
|
||||
|
|
|
@ -290,7 +290,6 @@ typedef struct MpegEncContext {
|
|||
uint16_t chroma_intra_matrix[64];
|
||||
uint16_t inter_matrix[64];
|
||||
uint16_t chroma_inter_matrix[64];
|
||||
int force_duplicated_matrix; ///< Force duplication of mjpeg matrices, useful for rtp streaming
|
||||
|
||||
int intra_quant_bias; ///< bias for the quantizer
|
||||
int inter_quant_bias; ///< bias for the quantizer
|
||||
|
@ -414,7 +413,6 @@ typedef struct MpegEncContext {
|
|||
struct MJpegContext *mjpeg_ctx;
|
||||
int esc_pos;
|
||||
int pred;
|
||||
int huffman;
|
||||
|
||||
/* MSMPEG4 specific */
|
||||
int mv_table_index;
|
||||
|
@ -575,6 +573,10 @@ typedef struct MpegEncContext {
|
|||
int noise_reduction;
|
||||
|
||||
int intra_penalty;
|
||||
|
||||
#if FF_API_MPEGVIDEO_OPTS
|
||||
int dummy; ///< used as target for deprecated options
|
||||
#endif
|
||||
} MpegEncContext;
|
||||
|
||||
/* mpegvideo_enc common options */
|
||||
|
@ -664,7 +666,7 @@ FF_MPV_OPT_CMP_FUNC, \
|
|||
#define FF_MPV_DEPRECATED_A53_CC_OPT \
|
||||
{ "a53cc", "Deprecated, does nothing", FF_MPV_OFFSET(a53_cc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
|
||||
#define FF_MPV_DEPRECATED_MATRIX_OPT \
|
||||
{ "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
|
||||
{ "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED },
|
||||
#define FF_MPV_DEPRECATED_BFRAME_OPTS \
|
||||
{ "b_strategy", "Deprecated, does nothing", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \
|
||||
{ "b_sensitivity", "Deprecated, does nothing", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \
|
||||
|
|
Loading…
Reference in New Issue