FFmpeg
proresenc_kostya_common.h
Go to the documentation of this file.
1 /*
2  * Apple ProRes encoder
3  *
4  * Copyright (c) 2011 Anatoliy Wasserman
5  * Copyright (c) 2012 Konstantin Shishkov
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_PRORESENC_KOSTYA_COMMON_H
25 #define AVCODEC_PRORESENC_KOSTYA_COMMON_H
26 
27 #include <stddef.h>
28 
30 #include "libavutil/log.h"
31 #include "libavutil/mem_internal.h"
32 #include "libavutil/pixfmt.h"
33 #include "fdctdsp.h"
34 
36 
37 #define CFACTOR_Y422 2
38 #define CFACTOR_Y444 3
39 
40 #define MAX_MBS_PER_SLICE 8
41 
42 #define MAX_PLANES 4
43 
44 #define NUM_MB_LIMITS 4
45 
46 #define MAX_STORED_Q 16
47 
48 enum {
56 };
57 
58 enum {
66 };
67 
68 struct AVCodecContext;
69 struct AVFrame;
70 
71 typedef struct prores_profile {
72  const char *full_name;
73  uint32_t tag;
74  int min_quant;
75  int max_quant;
77  int quant;
80 
81 typedef struct ProresContext {
82  AVClass *class;
84  DECLARE_ALIGNED(16, uint16_t, emu_buf)[16*16];
85  int16_t quants[MAX_STORED_Q][64];
87  int16_t custom_q[64];
88  int16_t custom_chroma_q[64];
89  const uint8_t *quant_mat;
90  const uint8_t *quant_chroma_mat;
91  const uint8_t *scantable;
92 
93  void (*fdct)(FDCTDSPContext *fdsp, const uint16_t *src,
94  ptrdiff_t linesize, int16_t *block);
96 
97  const struct AVFrame *pic;
103  int pictures_per_frame; // 1 for progressive, 2 for interlaced
109  int warn;
110 
111  char *vendor;
113 
115 
116  int profile;
118 
119  int *slice_q;
120 
122 } ProresContext;
123 
125  enum AVPixelFormat pixfmt);
126 
128  uint8_t **orig_buf, int flags,
130  enum AVColorTransferCharacteristic color_trc,
131  enum AVColorSpace colorspace);
132 
134 
136 
137 #endif // AVCODEC_PRORESENC_KOSTYA_COMMON_H
ProresContext::force_quant
int force_quant
Definition: proresenc_kostya_common.h:107
flags
const SwsFlags flags[]
Definition: swscale.c:61
ProresContext::quant_chroma_mat
const uint8_t * quant_chroma_mat
Definition: proresenc_kostya_common.h:90
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
FF_VISIBILITY_PUSH_HIDDEN
#define FF_VISIBILITY_PUSH_HIDDEN
Definition: attributes_internal.h:30
QUANT_MAT_PROXY_CHROMA
@ QUANT_MAT_PROXY_CHROMA
Definition: proresenc_kostya_common.h:60
ProresContext::fdsp
FDCTDSPContext fdsp
Definition: proresenc_anatoliy.c:185
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:666
mem_internal.h
QUANT_MAT_STANDARD
@ QUANT_MAT_STANDARD
Definition: proresenc_kostya_common.h:62
PRORES_PROFILE_LT
@ PRORES_PROFILE_LT
Definition: proresenc_kostya_common.h:51
NUM_MB_LIMITS
#define NUM_MB_LIMITS
Definition: proresenc_kostya_common.h:44
ProresContext::quants_chroma
int16_t quants_chroma[MAX_STORED_Q][64]
Definition: proresenc_kostya_common.h:86
ProresContext::vendor
char * vendor
Definition: proresenc_anatoliy.c:199
prores_profile::tag
uint32_t tag
Definition: proresenc_kostya_common.h:73
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
ProresContext::slices_width
int slices_width
Definition: proresenc_kostya_common.h:101
ProresContext::alpha_bits
int alpha_bits
Definition: proresenc_kostya_common.h:108
ProresContext
Definition: proresdec.h:43
ProresContext::tdata
struct ProresThreadData * tdata
Definition: proresenc_kostya_common.h:121
ProresContext::num_planes
int num_planes
Definition: proresenc_kostya_common.h:105
ProresContext::emu_buf
uint16_t emu_buf[16 *16]
Definition: proresenc_kostya_common.h:84
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:636
MAX_MBS_PER_SLICE
#define MAX_MBS_PER_SLICE
Definition: proresenc_kostya_common.h:40
ProresContext::profile_info
const struct prores_profile * profile_info
Definition: proresenc_kostya_common.h:117
QUANT_MAT_DEFAULT
@ QUANT_MAT_DEFAULT
Definition: proresenc_kostya_common.h:65
FDCTDSPContext
Definition: fdctdsp.h:28
ProresContext::slice_q
int * slice_q
Definition: proresenc_kostya_common.h:119
ProresContext::mbs_per_slice
int mbs_per_slice
Definition: proresenc_kostya_common.h:99
PRORES_PROFILE_STANDARD
@ PRORES_PROFILE_STANDARD
Definition: proresenc_kostya_common.h:52
ProresContext::custom_chroma_q
int16_t custom_chroma_q[64]
Definition: proresenc_kostya_common.h:88
PRORES_PROFILE_4444XQ
@ PRORES_PROFILE_4444XQ
Definition: proresenc_kostya_common.h:55
prores_profile::max_quant
int max_quant
Definition: proresenc_kostya_common.h:75
av_cold
#define av_cold
Definition: attributes.h:106
attributes_internal.h
PRORES_PROFILE_PROXY
@ PRORES_PROFILE_PROXY
Definition: proresenc_kostya_common.h:50
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
ProresContext::bits_per_mb
int bits_per_mb
Definition: proresenc_kostya_common.h:106
ProresContext::quants
int16_t quants[MAX_STORED_Q][64]
Definition: proresenc_kostya_common.h:85
ProresContext::profile
int profile
Definition: proresenc_kostya_common.h:116
MAX_STORED_Q
#define MAX_STORED_Q
Definition: proresenc_kostya_common.h:46
prores_profile::min_quant
int min_quant
Definition: proresenc_kostya_common.h:74
prores_profile::full_name
const char * full_name
Definition: proresenc_kostya_common.h:72
ProresContext::pic
const struct AVFrame * pic
Definition: proresenc_kostya_common.h:97
ProresContext::mb_width
int mb_width
Definition: proresenc_kostya_common.h:98
ProresContext::pictures_per_frame
int pictures_per_frame
Definition: proresenc_kostya_common.h:103
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
MAX_PLANES
#define MAX_PLANES
Definition: proresenc_kostya_common.h:42
ProresContext::quant_sel
int quant_sel
Definition: proresenc_kostya_common.h:112
ProresContext::blocks
int16_t blocks[MAX_PLANES][64 *4 *MAX_MBS_PER_SLICE]
Definition: proresenc_kostya_common.h:83
prores_profile::br_tab
int br_tab[NUM_MB_LIMITS]
Definition: proresenc_kostya_common.h:76
color_primaries
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition: csp.c:76
PRORES_PROFILE_AUTO
@ PRORES_PROFILE_AUTO
Definition: proresenc_kostya_common.h:49
ff_prores_kostya_write_picture_header
uint8_t * ff_prores_kostya_write_picture_header(ProresContext *ctx, uint8_t *buf)
Definition: proresenc_kostya_common.c:357
PRORES_PROFILE_HQ
@ PRORES_PROFILE_HQ
Definition: proresenc_kostya_common.h:53
ProresContext::chroma_factor
int chroma_factor
Definition: proresenc_kostya_common.h:100
ProresContext::scantable
const uint8_t * scantable
Definition: proresenc_anatoliy.c:193
ProresContext::custom_q
int16_t custom_q[64]
Definition: proresenc_kostya_common.h:87
ff_prores_kostya_encode_init
av_cold int ff_prores_kostya_encode_init(struct AVCodecContext *avctx, ProresContext *ctx, enum AVPixelFormat pixfmt)
Definition: proresenc_kostya_common.c:168
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:104
QUANT_MAT_PROXY
@ QUANT_MAT_PROXY
Definition: proresenc_kostya_common.h:59
QUANT_MAT_LT
@ QUANT_MAT_LT
Definition: proresenc_kostya_common.h:61
FF_VISIBILITY_POP_HIDDEN
#define FF_VISIBILITY_POP_HIDDEN
Definition: attributes_internal.h:31
QUANT_MAT_HQ
@ QUANT_MAT_HQ
Definition: proresenc_kostya_common.h:63
QUANT_MAT_XQ_LUMA
@ QUANT_MAT_XQ_LUMA
Definition: proresenc_kostya_common.h:64
prores_profile
Definition: proresenc_kostya_common.h:71
log.h
ProresContext::frame_size_upper_bound
int frame_size_upper_bound
Definition: proresenc_kostya_common.h:114
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:700
ProresContext::num_chroma_blocks
int num_chroma_blocks
Definition: proresenc_kostya_common.h:100
fdctdsp.h
ff_prores_kostya_write_frame_header
uint8_t * ff_prores_kostya_write_frame_header(struct AVCodecContext *avctx, ProresContext *ctx, uint8_t **orig_buf, int flags, enum AVColorPrimaries color_primaries, enum AVColorTransferCharacteristic color_trc, enum AVColorSpace colorspace)
Definition: proresenc_kostya_common.c:313
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:367
pixfmt.h
prores_profile::quant
int quant
Definition: proresenc_kostya_common.h:77
ProresContext::quant_mat
const uint8_t * quant_mat
Definition: proresenc_kostya_common.h:89
prores_profile::quant_chroma
int quant_chroma
Definition: proresenc_kostya_common.h:78
AVCodecContext
main external API structure.
Definition: avcodec.h:439
ProresContext::slices_per_picture
int slices_per_picture
Definition: proresenc_kostya_common.h:102
ProresThreadData
Definition: proresenc_kostya.c:48
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
ProresContext::fdct
void(* fdct)(FDCTDSPContext *fdsp, const uint16_t *src, ptrdiff_t linesize, int16_t *block)
Definition: proresenc_kostya_common.h:93
ProresContext::cur_picture_idx
int cur_picture_idx
Definition: proresenc_kostya_common.h:104
PRORES_PROFILE_4444
@ PRORES_PROFILE_4444
Definition: proresenc_kostya_common.h:54
ProresContext::warn
int warn
Definition: proresenc_kostya_common.h:109
src
#define src
Definition: vp8dsp.c:248
ProresContext::mb_height
unsigned mb_height
height of the current picture in mb
Definition: proresdec.h:54