... | ... |
@@ -277,7 +277,7 @@ following image formats are supported: |
277 | 277 |
@tab Only uncompressed GIFs are generated. |
278 | 278 |
@item BMP @tab X @tab X |
279 | 279 |
@tab Microsoft BMP image |
280 |
-@item DPX @tab @tab X |
|
280 |
+@item DPX @tab X @tab X |
|
281 | 281 |
@tab Digital Picture Exchange |
282 | 282 |
@item JPEG @tab X @tab X |
283 | 283 |
@tab Progressive JPEG is not supported. |
... | ... |
@@ -112,6 +112,7 @@ OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o \ |
112 | 112 |
ratecontrol.o mpeg12data.o \ |
113 | 113 |
mpegvideo.o |
114 | 114 |
OBJS-$(CONFIG_DPX_DECODER) += dpx.o |
115 |
+OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o |
|
115 | 116 |
OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinav.o |
116 | 117 |
OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinav.o |
117 | 118 |
OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o |
... | ... |
@@ -90,7 +90,7 @@ void avcodec_register_all(void) |
90 | 90 |
REGISTER_DECODER (CYUV, cyuv); |
91 | 91 |
REGISTER_DECODER (DFA, dfa); |
92 | 92 |
REGISTER_ENCDEC (DNXHD, dnxhd); |
93 |
- REGISTER_DECODER (DPX, dpx); |
|
93 |
+ REGISTER_ENCDEC (DPX, dpx); |
|
94 | 94 |
REGISTER_DECODER (DSICINVIDEO, dsicinvideo); |
95 | 95 |
REGISTER_ENCDEC (DVVIDEO, dvvideo); |
96 | 96 |
REGISTER_DECODER (DXA, dxa); |
97 | 97 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,136 @@ |
0 |
+/* |
|
1 |
+ * DPX (.dpx) image encoder |
|
2 |
+ * Copyright (c) 2011 Peter Ross <pross@xvid.org> |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include "libavutil/intreadwrite.h" |
|
22 |
+#include "libavutil/imgutils.h" |
|
23 |
+#include "avcodec.h" |
|
24 |
+ |
|
25 |
+typedef struct DPXContext { |
|
26 |
+ AVFrame picture; |
|
27 |
+ int big_endian; |
|
28 |
+ int bits_per_component; |
|
29 |
+ int descriptor; |
|
30 |
+} DPXContext; |
|
31 |
+ |
|
32 |
+static av_cold int encode_init(AVCodecContext *avctx) |
|
33 |
+{ |
|
34 |
+ DPXContext *s = avctx->priv_data; |
|
35 |
+ |
|
36 |
+ avctx->coded_frame = &s->picture; |
|
37 |
+ avctx->coded_frame->pict_type = FF_I_TYPE; |
|
38 |
+ avctx->coded_frame->key_frame = 1; |
|
39 |
+ |
|
40 |
+ s->big_endian = 1; |
|
41 |
+ s->bits_per_component = 8; |
|
42 |
+ s->descriptor = 50; /* RGB */ |
|
43 |
+ |
|
44 |
+ switch (avctx->pix_fmt) { |
|
45 |
+ case PIX_FMT_RGB24: |
|
46 |
+ break; |
|
47 |
+ case PIX_FMT_RGBA: |
|
48 |
+ s->descriptor = 51; /* RGBA */ |
|
49 |
+ break; |
|
50 |
+ case PIX_FMT_RGB48LE: |
|
51 |
+ s->big_endian = 0; |
|
52 |
+ case PIX_FMT_RGB48BE: |
|
53 |
+ s->bits_per_component = avctx->bits_per_raw_sample ? avctx->bits_per_raw_sample : 16; |
|
54 |
+ break; |
|
55 |
+ default: |
|
56 |
+ av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n"); |
|
57 |
+ return -1; |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ return 0; |
|
61 |
+} |
|
62 |
+ |
|
63 |
+#define write16(p, value) \ |
|
64 |
+do { \ |
|
65 |
+ if (s->big_endian) AV_WB16(p, value); \ |
|
66 |
+ else AV_WL16(p, value); \ |
|
67 |
+} while(0) |
|
68 |
+ |
|
69 |
+#define write32(p, value) \ |
|
70 |
+do { \ |
|
71 |
+ if (s->big_endian) AV_WB32(p, value); \ |
|
72 |
+ else AV_WL32(p, value); \ |
|
73 |
+} while(0) |
|
74 |
+ |
|
75 |
+static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data) |
|
76 |
+{ |
|
77 |
+ DPXContext *s = avctx->priv_data; |
|
78 |
+ int size; |
|
79 |
+ |
|
80 |
+#define HEADER_SIZE 1664 /* DPX Generic header */ |
|
81 |
+ if (buf_size < HEADER_SIZE) |
|
82 |
+ return -1; |
|
83 |
+ |
|
84 |
+ memset(buf, 0, HEADER_SIZE); |
|
85 |
+ |
|
86 |
+ /* File information header */ |
|
87 |
+ write32(buf, MKBETAG('S','D','P','X')); |
|
88 |
+ write32(buf + 4, HEADER_SIZE); |
|
89 |
+ memcpy (buf + 8, "V1.0", 4); |
|
90 |
+ write32(buf + 20, 1); /* new image */ |
|
91 |
+ write32(buf + 24, HEADER_SIZE); |
|
92 |
+ memcpy (buf + 160, LIBAVCODEC_IDENT, FFMIN(sizeof(LIBAVCODEC_IDENT), 100)); |
|
93 |
+ write32(buf + 660, 0xFFFFFFFF); /* unencrypted */ |
|
94 |
+ |
|
95 |
+ /* Image information header */ |
|
96 |
+ write16(buf + 768, 0); /* orientation; left to right, top to bottom */ |
|
97 |
+ write16(buf + 770, 1); /* number of elements */ |
|
98 |
+ write32(buf + 772, avctx->width); |
|
99 |
+ write32(buf + 776, avctx->height); |
|
100 |
+ buf[800] = s->descriptor; |
|
101 |
+ buf[801] = 2; /* linear transfer */ |
|
102 |
+ buf[802] = 2; /* linear colorimetric */ |
|
103 |
+ buf[803] = s->bits_per_component; |
|
104 |
+ |
|
105 |
+ /* Image source information header */ |
|
106 |
+ write32(buf + 1628, avctx->sample_aspect_ratio.num); |
|
107 |
+ write32(buf + 1632, avctx->sample_aspect_ratio.den); |
|
108 |
+ |
|
109 |
+ size = avpicture_layout((AVPicture*)data, avctx->pix_fmt, |
|
110 |
+ avctx->width, avctx->height, |
|
111 |
+ buf + HEADER_SIZE, buf_size - HEADER_SIZE); |
|
112 |
+ if (size < 0) |
|
113 |
+ return size; |
|
114 |
+ |
|
115 |
+ size += HEADER_SIZE; |
|
116 |
+ |
|
117 |
+ write32(buf + 16, size); /* file size */ |
|
118 |
+ return size; |
|
119 |
+} |
|
120 |
+ |
|
121 |
+AVCodec ff_dpx_encoder = { |
|
122 |
+ "dpx", |
|
123 |
+ AVMEDIA_TYPE_VIDEO, |
|
124 |
+ CODEC_ID_DPX, |
|
125 |
+ sizeof(DPXContext), |
|
126 |
+ encode_init, |
|
127 |
+ encode_frame, |
|
128 |
+ .pix_fmts= (const enum PixelFormat[]){ |
|
129 |
+ PIX_FMT_RGB24, |
|
130 |
+ PIX_FMT_RGBA, |
|
131 |
+ PIX_FMT_RGB48LE, |
|
132 |
+ PIX_FMT_RGB48BE, |
|
133 |
+ PIX_FMT_NONE}, |
|
134 |
+ .long_name = NULL_IF_CONFIG_SMALL("DPX image"), |
|
135 |
+}; |
... | ... |
@@ -21,7 +21,7 @@ |
21 | 21 |
#define AVCODEC_VERSION_H |
22 | 22 |
|
23 | 23 |
#define LIBAVCODEC_VERSION_MAJOR 52 |
24 |
-#define LIBAVCODEC_VERSION_MINOR 116 |
|
24 |
+#define LIBAVCODEC_VERSION_MINOR 117 |
|
25 | 25 |
#define LIBAVCODEC_VERSION_MICRO 0 |
26 | 26 |
|
27 | 27 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |