FFmpeg: libavcodec/dpxenc.c Source File
Go to the documentation of this file. 1 /*
2 * DPX (.dpx) image encoder
3 * Copyright (c) 2011 Peter Ross <pross@xvid.org>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
30
38
40 {
43
45 s->bits_per_component =
desc->comp[0].depth;
46 s->num_components =
desc->nb_components;
49
53 break;
58 break;
67 break;
72 break;
73 }
74
75 return 0;
76 }
77
79 {
82 }
83
85 {
88 }
89
90 #define write16(p, value) write16_internal(s->big_endian, p, value)
91 #define write32(p, value) write32_internal(s->big_endian, p, value)
92
95 {
97 const uint8_t *
src = pic->
data[0];
98 int x, y;
99
100 for (y = 0; y < avctx->
height; y++) {
101 for (x = 0; x < avctx->
width; x++) {
107 } else {
111 }
114 }
116 }
117 }
118
120 {
124
125 for (y = 0; y < avctx->
height; y++) {
126 for (x = 0; x < avctx->
width; x++) {
132 } else {
136 }
139 }
140 for (
i = 0;
i < 3;
i++)
142 }
143 }
144
146 {
148 const uint16_t *
src[3] = {(uint16_t*)pic->
data[0],
149 (uint16_t*)pic->
data[1],
150 (uint16_t*)pic->
data[2]};
152 pad = avctx->
width*6;
153 pad = (
FFALIGN(pad, 4) - pad) >> 1;
154 for (y = 0; y < avctx->
height; y++) {
155 for (x = 0; x < avctx->
width; x++) {
161 } else {
165 }
166 for (
i = 0;
i < 3;
i++,
dst += 2)
168 }
169 for (
i = 0;
i < pad;
i++,
dst += 2)
171 for (
i = 0;
i < 3;
i++)
173 }
174 }
175
178 {
181 uint8_t *buf;
182 int color_trc, color_spec;
183
184 #define HEADER_SIZE 1664 /* DPX Generic header */
185 if (
s->bits_per_component == 10)
187 else if (
s->bits_per_component == 12) {
188 // 3 components, 12 bits put on 16 bits
193 } else {
194 // N components, M bits
195 len = avctx->
width *
s->num_components *
s->bits_per_component >> 3;
199 }
203
205
206 /* File information header */
209 memcpy (buf + 8, "V1.0", 4);
210 write32(buf + 20, 1);
/* new image */
214 write32(buf + 660, 0xFFFFFFFF);
/* unencrypted */
215
216 /* Image information header */
217 write16(buf + 768, 0);
/* orientation; left to right, top to bottom */
218 write16(buf + 770, 1);
/* number of elements */
221 buf[800] =
s->descriptor;
222
226 break;
227 default:
231 break;
234 break;
237 break;
240 break;
241 }
242 buf[801] = color_trc;
243
247 break;
248 default:
252 break;
255 break;
258 break;
259 }
260 buf[802] = color_spec;
261
262 buf[803] =
s->bits_per_component;
263 write16(buf + 804, (
s->bits_per_component == 10 ||
s->bits_per_component == 12) ?
264 1 : 0); /* packing method */
266
267 /* Image source information header */
270
271 switch(
s->bits_per_component) {
272 case 8:
273 case 16:
274 if (need_align) {
275 int j;
276 const uint8_t *
src =
frame->data[0];
281 memset(
dst +
len, 0, need_align);
284 }
285 } else {
287 (
const uint8_t**)
frame->data,
frame->linesize,
290 }
293 break;
294 case 10:
297 else
299 break;
300 case 12:
302 break;
303 default:
305 return -1;
306 }
307
309
311
312 *got_packet = 1;
313
314 return 0;
315 }
316
333 };
@ DPX_COL_SPEC_ITU_R_624_4_PAL
#define CODEC_PIXFMTS(...)
#define AV_LOG_WARNING
Something somehow does not look correct.
@ AV_PIX_FMT_GBRP10BE
planar GBR 4:4:4 30bpp, big-endian
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
#define write16(p, value)
This structure describes decoded (raw) audio or video data.
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static av_always_inline void write16_internal(int big_endian, void *p, int value)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
AVCodec p
The public AVCodec.
const FFCodec ff_dpx_encoder
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
int flags
AV_CODEC_FLAG_*.
#define FF_CODEC_ENCODE_CB(func)
@ DPX_COL_SPEC_ITU_R_709_4
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void write32_internal(int big_endian, void *p, int value)
@ AV_PIX_FMT_GBRP12LE
planar GBR 4:4:4 36bpp, little-endian
@ DPX_TRC_ITU_R_624_4_PAL
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
#define write32(p, value)
@ AV_PIX_FMT_GBRP10LE
planar GBR 4:4:4 30bpp, little-endian
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
@ AV_PIX_FMT_RGBA64LE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int(* init)(AVBSFContext *ctx)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint8_t *dst)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define MKBETAG(a, b, c, d)
@ DPX_COL_SPEC_UNSPECIFIED_VIDEO
@ AVCOL_TRC_BT709
also ITU-R BT1361
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define i(width, name, range_min, range_max)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
@ AV_PIX_FMT_GBRP12BE
planar GBR 4:4:4 36bpp, big-endian
@ DPX_TRC_UNSPECIFIED_VIDEO
main external API structure.
static void encode_gbrp10(AVCodecContext *avctx, const AVFrame *pic, uint8_t *dst)
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVFrame *pic, uint8_t *dst)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static av_cold int encode_init(AVCodecContext *avctx)
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int av_image_copy_to_buffer(uint8_t *dst, int dst_size, const uint8_t *const src_data[4], const int src_linesize[4], enum AVPixelFormat pix_fmt, int width, int height, int align)
Copy image data from an image into a buffer.
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Generated on Sat Oct 18 2025 19:22:00 for FFmpeg by
doxygen
1.8.17