xref: /third_party/ffmpeg/libavcodec/dnxhdenc.h (revision cabdff1a)
1/*
2 * VC3/DNxHD encoder structure definitions and prototypes
3 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
4 *
5 * VC-3 encoder funded by the British Broadcasting Corporation
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef AVCODEC_DNXHDENC_H
25#define AVCODEC_DNXHDENC_H
26
27#include <stdint.h>
28
29#include "config.h"
30
31#include "libavutil/mem_internal.h"
32
33#include "mpegvideo.h"
34#include "dnxhddata.h"
35
36typedef struct RCCMPEntry {
37    uint32_t mb;
38    int value;
39} RCCMPEntry;
40
41typedef struct RCEntry {
42    int ssd;
43    int bits;
44} RCEntry;
45
46typedef struct DNXHDEncContext {
47    AVClass *class;
48    BlockDSPContext bdsp;
49    MpegEncContext m; ///< Used for quantization dsp functions
50
51    int cid;
52    int profile;
53    int bit_depth;
54    int is_444;
55    const CIDEntry *cid_table;
56    uint8_t *msip; ///< Macroblock Scan Indexes Payload
57    uint32_t *slice_size;
58    uint32_t *slice_offs;
59
60    struct DNXHDEncContext *thread[MAX_THREADS];
61
62    // Because our samples are either 8 or 16 bits for 8-bit and 10-bit
63    // encoding respectively, these refer either to bytes or to two-byte words.
64    unsigned dct_y_offset;
65    unsigned dct_uv_offset;
66    unsigned block_width_l2;
67
68    int frame_size;
69    int coding_unit_size;
70    int data_offset;
71
72    int interlaced;
73    int cur_field;
74
75    int nitris_compat;
76    unsigned min_padding;
77    int intra_quant_bias;
78
79    DECLARE_ALIGNED(32, int16_t, blocks)[12][64];
80    DECLARE_ALIGNED(16, uint8_t, edge_buf_y)[512]; // has to hold 16x16 uint16 when depth=10
81    DECLARE_ALIGNED(16, uint8_t, edge_buf_uv)[2][512]; // has to hold 16x16 uint16_t when depth=10
82
83    int      (*qmatrix_c)     [64];
84    int      (*qmatrix_l)     [64];
85    uint16_t (*qmatrix_l16)[2][64];
86    uint16_t (*qmatrix_c16)[2][64];
87
88    unsigned frame_bits;
89    uint8_t *src[3];
90
91    uint32_t *orig_vlc_codes;
92    uint8_t  *orig_vlc_bits;
93    uint32_t *vlc_codes;
94    uint8_t  *vlc_bits;
95    uint16_t *run_codes;
96    uint8_t  *run_bits;
97
98    /** Rate control */
99    unsigned slice_bits;
100    unsigned qscale;
101    unsigned lambda;
102
103    uint32_t *mb_bits;
104    uint8_t  *mb_qscale;
105
106    RCCMPEntry *mb_cmp;
107    RCCMPEntry *mb_cmp_tmp;
108    RCEntry    *mb_rc;
109
110    void (*get_pixels_8x4_sym)(int16_t *av_restrict /* align 16 */ block,
111                               const uint8_t *pixels, ptrdiff_t line_size);
112} DNXHDEncContext;
113
114void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx);
115
116#endif /* AVCODEC_DNXHDENC_H */
117