Originally committed as revision 24533 to svn://svn.ffmpeg.org/ffmpeg/trunk
Stefan Gehrer authored on 2010/07/27 16:18:36... | ... |
@@ -181,6 +181,7 @@ External library support: |
181 | 181 |
native implementation exists [no] |
182 | 182 |
--enable-libvpx enable VP8 support via libvpx [no] |
183 | 183 |
--enable-libx264 enable H.264 encoding via x264 [no] |
184 |
+ --enable-libxavs enable AVS encoding via xavs [no] |
|
184 | 185 |
--enable-libxvid enable Xvid encoding via xvidcore, |
185 | 186 |
native MPEG-4/Xvid encoder exists [no] |
186 | 187 |
--enable-mlib enable Sun medialib [no] |
... | ... |
@@ -884,6 +885,7 @@ CONFIG_LIST=" |
884 | 884 |
libvorbis |
885 | 885 |
libvpx |
886 | 886 |
libx264 |
887 |
+ libxavs |
|
887 | 888 |
libxvid |
888 | 889 |
lpc |
889 | 890 |
lsp |
... | ... |
@@ -1318,6 +1320,7 @@ libvorbis_encoder_deps="libvorbis" |
1318 | 1318 |
libvpx_decoder_deps="libvpx" |
1319 | 1319 |
libvpx_encoder_deps="libvpx" |
1320 | 1320 |
libx264_encoder_deps="libx264" |
1321 |
+libxavs_encoder_deps="libxavs" |
|
1321 | 1322 |
libxvid_encoder_deps="libxvid" |
1322 | 1323 |
|
1323 | 1324 |
# demuxers / muxers |
... | ... |
@@ -2371,6 +2374,7 @@ die_license_disabled() { |
2371 | 2371 |
} |
2372 | 2372 |
|
2373 | 2373 |
die_license_disabled gpl libx264 |
2374 |
+die_license_disabled gpl libxavs |
|
2374 | 2375 |
die_license_disabled gpl libxvid |
2375 | 2376 |
die_license_disabled gpl postproc |
2376 | 2377 |
die_license_disabled gpl x11grab |
... | ... |
@@ -2676,6 +2680,7 @@ enabled libvpx && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec |
2676 | 2676 |
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 && |
2677 | 2677 |
{ check_cpp_condition x264.h "X264_BUILD >= 98" || |
2678 | 2678 |
die "ERROR: libx264 version must be >= 0.98."; } |
2679 |
+enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs |
|
2679 | 2680 |
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore |
2680 | 2681 |
enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib |
2681 | 2682 |
|
... | ... |
@@ -2948,6 +2953,7 @@ echo "libtheora enabled ${libtheora-no}" |
2948 | 2948 |
echo "libvorbis enabled ${libvorbis-no}" |
2949 | 2949 |
echo "libvpx enabled ${libvpx-no}" |
2950 | 2950 |
echo "libx264 enabled ${libx264-no}" |
2951 |
+echo "libxavs enabled ${libxavs-no}" |
|
2951 | 2952 |
echo "libxvid enabled ${libxvid-no}" |
2952 | 2953 |
echo "zlib enabled ${zlib-no}" |
2953 | 2954 |
echo "bzlib enabled ${bzlib-no}" |
... | ... |
@@ -156,7 +156,7 @@ library: |
156 | 156 |
@item QCP @tab @tab X |
157 | 157 |
@item raw ADTS (AAC) @tab X @tab X |
158 | 158 |
@item raw AC-3 @tab X @tab X |
159 |
-@item raw Chinese AVS video @tab @tab X |
|
159 |
+@item raw Chinese AVS video @tab X @tab X |
|
160 | 160 |
@item raw CRI ADX @tab X @tab X |
161 | 161 |
@item raw Dirac @tab X @tab X |
162 | 162 |
@item raw DNxHD @tab X @tab X |
... | ... |
@@ -350,8 +350,8 @@ following image formats are supported: |
350 | 350 |
@tab fourcc: CSCD |
351 | 351 |
@item CD+G @tab @tab X |
352 | 352 |
@tab Video codec for CD+G karaoke disks |
353 |
-@item Chinese AVS video @tab @tab X |
|
354 |
- @tab AVS1-P2, JiZhun profile |
|
353 |
+@item Chinese AVS video @tab E @tab X |
|
354 |
+ @tab AVS1-P2, JiZhun profile, encoding through external library libxavs |
|
355 | 355 |
@item Delphine Software International CIN video @tab @tab X |
356 | 356 |
@tab Codec used in Delphine Software International games. |
357 | 357 |
@item Cinepak @tab @tab X |
... | ... |
@@ -548,6 +548,7 @@ OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o |
548 | 548 |
OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o |
549 | 549 |
OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o |
550 | 550 |
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o |
551 |
+OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o |
|
551 | 552 |
OBJS-$(CONFIG_LIBXVID) += libxvidff.o libxvid_rc.o |
552 | 553 |
|
553 | 554 |
# parsers |
... | ... |
@@ -356,6 +356,7 @@ void avcodec_register_all(void) |
356 | 356 |
REGISTER_ENCODER (LIBVORBIS, libvorbis); |
357 | 357 |
REGISTER_ENCDEC (LIBVPX, libvpx); |
358 | 358 |
REGISTER_ENCODER (LIBX264, libx264); |
359 |
+ REGISTER_ENCODER (LIBXAVS, libxavs); |
|
359 | 360 |
REGISTER_ENCODER (LIBXVID, libxvid); |
360 | 361 |
|
361 | 362 |
/* parsers */ |
362 | 363 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,351 @@ |
0 |
+/* |
|
1 |
+ * AVS encoding using the xavs library |
|
2 |
+ * Copyright (C) 2010 Amanda, Y.N. Wu <amanda11192003@gmail.com> |
|
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 <stdio.h> |
|
22 |
+#include <stdlib.h> |
|
23 |
+#include <string.h> |
|
24 |
+#include <math.h> |
|
25 |
+#include <stdint.h> |
|
26 |
+#include <xavs.h> |
|
27 |
+#include "avcodec.h" |
|
28 |
+ |
|
29 |
+#define END_OF_STREAM 0x001 |
|
30 |
+ |
|
31 |
+#define XAVS_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ |
|
32 |
+#define XAVS_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ |
|
33 |
+#define XAVS_PART_B8X8 0x100 /* Analyze b16x8, b*/ |
|
34 |
+ |
|
35 |
+typedef struct XavsContext { |
|
36 |
+ xavs_param_t params; |
|
37 |
+ xavs_t *enc; |
|
38 |
+ xavs_picture_t pic; |
|
39 |
+ uint8_t *sei; |
|
40 |
+ int sei_size; |
|
41 |
+ AVFrame out_pic; |
|
42 |
+ int end_of_stream; |
|
43 |
+} XavsContext; |
|
44 |
+ |
|
45 |
+static void XAVS_log(void *p, int level, const char *fmt, va_list args) |
|
46 |
+{ |
|
47 |
+ static const int level_map[] = { |
|
48 |
+ [XAVS_LOG_ERROR] = AV_LOG_ERROR, |
|
49 |
+ [XAVS_LOG_WARNING] = AV_LOG_WARNING, |
|
50 |
+ [XAVS_LOG_INFO] = AV_LOG_INFO, |
|
51 |
+ [XAVS_LOG_DEBUG] = AV_LOG_DEBUG |
|
52 |
+ }; |
|
53 |
+ |
|
54 |
+ if (level < 0 || level > XAVS_LOG_DEBUG) |
|
55 |
+ return; |
|
56 |
+ |
|
57 |
+ av_vlog(p, level_map[level], fmt, args); |
|
58 |
+} |
|
59 |
+ |
|
60 |
+static int encode_nals(AVCodecContext *ctx, uint8_t *buf, |
|
61 |
+ int size, xavs_nal_t *nals, |
|
62 |
+ int nnal, int skip_sei) |
|
63 |
+{ |
|
64 |
+ XavsContext *x4 = ctx->priv_data; |
|
65 |
+ uint8_t *p = buf; |
|
66 |
+ int i, s; |
|
67 |
+ |
|
68 |
+ /* Write the SEI as part of the first frame. */ |
|
69 |
+ if (x4->sei_size > 0 && nnal > 0) { |
|
70 |
+ memcpy(p, x4->sei, x4->sei_size); |
|
71 |
+ p += x4->sei_size; |
|
72 |
+ x4->sei_size = 0; |
|
73 |
+ } |
|
74 |
+ |
|
75 |
+ for (i = 0; i < nnal; i++) { |
|
76 |
+ /* Don't put the SEI in extradata. */ |
|
77 |
+ if (skip_sei && nals[i].i_type == NAL_SEI) { |
|
78 |
+ x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 ); |
|
79 |
+ if (xavs_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0) |
|
80 |
+ return -1; |
|
81 |
+ |
|
82 |
+ continue; |
|
83 |
+ } |
|
84 |
+ s = xavs_nal_encode(p, &size, 1, nals + i); |
|
85 |
+ if (s < 0) |
|
86 |
+ return -1; |
|
87 |
+ p += s; |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ return p - buf; |
|
91 |
+} |
|
92 |
+ |
|
93 |
+static int XAVS_frame(AVCodecContext *ctx, uint8_t *buf, |
|
94 |
+ int bufsize, void *data) |
|
95 |
+{ |
|
96 |
+ XavsContext *x4 = ctx->priv_data; |
|
97 |
+ AVFrame *frame = data; |
|
98 |
+ xavs_nal_t *nal; |
|
99 |
+ int nnal, i; |
|
100 |
+ xavs_picture_t pic_out; |
|
101 |
+ |
|
102 |
+ x4->pic.img.i_csp = XAVS_CSP_I420; |
|
103 |
+ x4->pic.img.i_plane = 3; |
|
104 |
+ |
|
105 |
+ if (frame) { |
|
106 |
+ for (i = 0; i < 3; i++) { |
|
107 |
+ x4->pic.img.plane[i] = frame->data[i]; |
|
108 |
+ x4->pic.img.i_stride[i] = frame->linesize[i]; |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ x4->pic.i_pts = frame->pts; |
|
112 |
+ x4->pic.i_type = XAVS_TYPE_AUTO; |
|
113 |
+ } |
|
114 |
+ |
|
115 |
+ if (xavs_encoder_encode(x4->enc, &nal, &nnal, |
|
116 |
+ frame? &x4->pic: NULL, &pic_out) < 0) |
|
117 |
+ return -1; |
|
118 |
+ |
|
119 |
+ bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0); |
|
120 |
+ |
|
121 |
+ if (bufsize < 0) |
|
122 |
+ return -1; |
|
123 |
+ |
|
124 |
+ if (!bufsize && !frame && !(x4->end_of_stream)){ |
|
125 |
+ buf[bufsize] = 0x0; |
|
126 |
+ buf[bufsize+1] = 0x0; |
|
127 |
+ buf[bufsize+2] = 0x01; |
|
128 |
+ buf[bufsize+3] = 0xb1; |
|
129 |
+ bufsize += 4; |
|
130 |
+ x4->end_of_stream = END_OF_STREAM; |
|
131 |
+ return bufsize; |
|
132 |
+ } |
|
133 |
+ /* FIXME: libxavs now provides DTS */ |
|
134 |
+ /* but AVFrame doesn't have a field for it. */ |
|
135 |
+ x4->out_pic.pts = pic_out.i_pts; |
|
136 |
+ |
|
137 |
+ switch (pic_out.i_type) { |
|
138 |
+ case XAVS_TYPE_IDR: |
|
139 |
+ case XAVS_TYPE_I: |
|
140 |
+ x4->out_pic.pict_type = FF_I_TYPE; |
|
141 |
+ break; |
|
142 |
+ case XAVS_TYPE_P: |
|
143 |
+ x4->out_pic.pict_type = FF_P_TYPE; |
|
144 |
+ break; |
|
145 |
+ case XAVS_TYPE_B: |
|
146 |
+ case XAVS_TYPE_BREF: |
|
147 |
+ x4->out_pic.pict_type = FF_B_TYPE; |
|
148 |
+ break; |
|
149 |
+ } |
|
150 |
+ |
|
151 |
+ /* There is no IDR frame in AVS JiZhun */ |
|
152 |
+ /* Sequence header is used as a flag */ |
|
153 |
+ x4->out_pic.key_frame = pic_out.i_type == XAVS_TYPE_I; |
|
154 |
+ |
|
155 |
+ x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; |
|
156 |
+ |
|
157 |
+ return bufsize; |
|
158 |
+} |
|
159 |
+ |
|
160 |
+static av_cold int XAVS_close(AVCodecContext *avctx) |
|
161 |
+{ |
|
162 |
+ XavsContext *x4 = avctx->priv_data; |
|
163 |
+ |
|
164 |
+ av_freep(&avctx->extradata); |
|
165 |
+ av_free(x4->sei); |
|
166 |
+ |
|
167 |
+ if (x4->enc) |
|
168 |
+ xavs_encoder_close(x4->enc); |
|
169 |
+ |
|
170 |
+ return 0; |
|
171 |
+} |
|
172 |
+ |
|
173 |
+static av_cold int XAVS_init(AVCodecContext *avctx) |
|
174 |
+{ |
|
175 |
+ XavsContext *x4 = avctx->priv_data; |
|
176 |
+ |
|
177 |
+ x4->sei_size = 0; |
|
178 |
+ xavs_param_default(&x4->params); |
|
179 |
+ |
|
180 |
+ x4->params.pf_log = XAVS_log; |
|
181 |
+ x4->params.p_log_private = avctx; |
|
182 |
+ x4->params.i_keyint_max = avctx->gop_size; |
|
183 |
+ x4->params.rc.i_bitrate = avctx->bit_rate / 1000; |
|
184 |
+ x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; |
|
185 |
+ x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; |
|
186 |
+ x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; |
|
187 |
+ if (avctx->flags & CODEC_FLAG_PASS2) { |
|
188 |
+ x4->params.rc.b_stat_read = 1; |
|
189 |
+ } else { |
|
190 |
+ if (avctx->crf) { |
|
191 |
+ x4->params.rc.i_rc_method = XAVS_RC_CRF; |
|
192 |
+ x4->params.rc.f_rf_constant = avctx->crf; |
|
193 |
+ } else if (avctx->cqp > -1) { |
|
194 |
+ x4->params.rc.i_rc_method = XAVS_RC_CQP; |
|
195 |
+ x4->params.rc.i_qp_constant = avctx->cqp; |
|
196 |
+ } |
|
197 |
+ } |
|
198 |
+ |
|
199 |
+ /* if neither crf nor cqp modes are selected we have to enable the RC */ |
|
200 |
+ /* we do it this way because we cannot check if the bitrate has been set */ |
|
201 |
+ if (!(avctx->crf || (avctx->cqp > -1))) |
|
202 |
+ x4->params.rc.i_rc_method = XAVS_RC_ABR; |
|
203 |
+ |
|
204 |
+ x4->params.i_bframe = avctx->max_b_frames; |
|
205 |
+ /* cabac is not included in AVS JiZhun Profile */ |
|
206 |
+ x4->params.b_cabac = 0; |
|
207 |
+ |
|
208 |
+ x4->params.i_bframe_adaptive = avctx->b_frame_strategy; |
|
209 |
+ x4->params.i_bframe_bias = avctx->bframebias; |
|
210 |
+ |
|
211 |
+ avctx->has_b_frames = !!avctx->max_b_frames; |
|
212 |
+ |
|
213 |
+ /* AVS doesn't allow B picture as reference */ |
|
214 |
+ /* The max allowed reference frame number of B is 2 */ |
|
215 |
+ x4->params.i_keyint_min = avctx->keyint_min; |
|
216 |
+ if (x4->params.i_keyint_min > x4->params.i_keyint_max) |
|
217 |
+ x4->params.i_keyint_min = x4->params.i_keyint_max; |
|
218 |
+ |
|
219 |
+ x4->params.i_scenecut_threshold = avctx->scenechange_threshold; |
|
220 |
+ |
|
221 |
+ // x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER; |
|
222 |
+ x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha; |
|
223 |
+ x4->params.i_deblocking_filter_beta = avctx->deblockbeta; |
|
224 |
+ |
|
225 |
+ x4->params.rc.i_qp_min = avctx->qmin; |
|
226 |
+ x4->params.rc.i_qp_max = avctx->qmax; |
|
227 |
+ x4->params.rc.i_qp_step = avctx->max_qdiff; |
|
228 |
+ |
|
229 |
+ x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */ |
|
230 |
+ x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */ |
|
231 |
+ x4->params.rc.f_complexity_blur = avctx->complexityblur; |
|
232 |
+ |
|
233 |
+ x4->params.i_frame_reference = avctx->refs; |
|
234 |
+ |
|
235 |
+ x4->params.i_width = avctx->width; |
|
236 |
+ x4->params.i_height = avctx->height; |
|
237 |
+ x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num; |
|
238 |
+ x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den; |
|
239 |
+ /* This is only used for counting the fps */ |
|
240 |
+ x4->params.i_fps_num = avctx->time_base.den; |
|
241 |
+ x4->params.i_fps_den = avctx->time_base.num; |
|
242 |
+ x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16; |
|
243 |
+ if (avctx->partitions) { |
|
244 |
+ if (avctx->partitions & XAVS_PART_I8X8) |
|
245 |
+ x4->params.analyse.inter |= XAVS_ANALYSE_I8x8; |
|
246 |
+ |
|
247 |
+ if (avctx->partitions & XAVS_PART_P8X8) |
|
248 |
+ x4->params.analyse.inter |= XAVS_ANALYSE_PSUB16x16; |
|
249 |
+ |
|
250 |
+ if (avctx->partitions & XAVS_PART_B8X8) |
|
251 |
+ x4->params.analyse.inter |= XAVS_ANALYSE_BSUB16x16; |
|
252 |
+ } |
|
253 |
+ |
|
254 |
+ x4->params.analyse.i_direct_mv_pred = avctx->directpred; |
|
255 |
+ |
|
256 |
+ x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; |
|
257 |
+ |
|
258 |
+ switch (avctx->me_method) { |
|
259 |
+ case ME_EPZS: |
|
260 |
+ x4->params.analyse.i_me_method = XAVS_ME_DIA; |
|
261 |
+ break; |
|
262 |
+ case ME_HEX: |
|
263 |
+ x4->params.analyse.i_me_method = XAVS_ME_HEX; |
|
264 |
+ break; |
|
265 |
+ case ME_UMH: |
|
266 |
+ x4->params.analyse.i_me_method = XAVS_ME_UMH; |
|
267 |
+ break; |
|
268 |
+ case ME_FULL: |
|
269 |
+ x4->params.analyse.i_me_method = XAVS_ME_ESA; |
|
270 |
+ break; |
|
271 |
+ case ME_TESA: |
|
272 |
+ x4->params.analyse.i_me_method = XAVS_ME_TESA; |
|
273 |
+ break; |
|
274 |
+ default: |
|
275 |
+ x4->params.analyse.i_me_method = XAVS_ME_HEX; |
|
276 |
+ } |
|
277 |
+ |
|
278 |
+ x4->params.analyse.i_me_range = avctx->me_range; |
|
279 |
+ x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; |
|
280 |
+ |
|
281 |
+ x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; |
|
282 |
+ x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; |
|
283 |
+ /* AVS P2 only enables 8x8 transform */ |
|
284 |
+ x4->params.analyse.b_transform_8x8 = 1; //avctx->flags2 & CODEC_FLAG2_8X8DCT; |
|
285 |
+ x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; |
|
286 |
+ |
|
287 |
+ x4->params.analyse.i_trellis = avctx->trellis; |
|
288 |
+ x4->params.analyse.i_noise_reduction = avctx->noise_reduction; |
|
289 |
+ |
|
290 |
+ if (avctx->level > 0) |
|
291 |
+ x4->params.i_level_idc = avctx->level; |
|
292 |
+ |
|
293 |
+ x4->params.rc.f_rate_tolerance = |
|
294 |
+ (float)avctx->bit_rate_tolerance/avctx->bit_rate; |
|
295 |
+ |
|
296 |
+ if ((avctx->rc_buffer_size) && |
|
297 |
+ (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) { |
|
298 |
+ x4->params.rc.f_vbv_buffer_init = |
|
299 |
+ (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; |
|
300 |
+ } else |
|
301 |
+ x4->params.rc.f_vbv_buffer_init = 0.9; |
|
302 |
+ |
|
303 |
+ /* TAG:do we have MB tree RC method */ |
|
304 |
+ /* what is the RC method we are now using? Default NO */ |
|
305 |
+ x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); |
|
306 |
+ x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); |
|
307 |
+ x4->params.rc.f_pb_factor = avctx->b_quant_factor; |
|
308 |
+ x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; |
|
309 |
+ |
|
310 |
+ x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; |
|
311 |
+ x4->params.i_log_level = XAVS_LOG_DEBUG; |
|
312 |
+ x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; |
|
313 |
+ x4->params.i_threads = avctx->thread_count; |
|
314 |
+ x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; |
|
315 |
+ |
|
316 |
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) |
|
317 |
+ x4->params.b_repeat_headers = 0; |
|
318 |
+ |
|
319 |
+ x4->enc = xavs_encoder_open(&x4->params); |
|
320 |
+ if (!x4->enc) |
|
321 |
+ return -1; |
|
322 |
+ |
|
323 |
+ avctx->coded_frame = &x4->out_pic; |
|
324 |
+ /* TAG: Do we have GLOBAL HEADER in AVS */ |
|
325 |
+ /* We Have PPS and SPS in AVS */ |
|
326 |
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { |
|
327 |
+ xavs_nal_t *nal; |
|
328 |
+ int nnal, s; |
|
329 |
+ |
|
330 |
+ s = xavs_encoder_headers(x4->enc, &nal, &nnal); |
|
331 |
+ |
|
332 |
+ avctx->extradata = av_malloc(s); |
|
333 |
+ avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1); |
|
334 |
+ } |
|
335 |
+ return 0; |
|
336 |
+} |
|
337 |
+ |
|
338 |
+AVCodec libxavs_encoder = { |
|
339 |
+ .name = "libxavs", |
|
340 |
+ .type = CODEC_TYPE_VIDEO, |
|
341 |
+ .id = CODEC_ID_CAVS, |
|
342 |
+ .priv_data_size = sizeof(XavsContext), |
|
343 |
+ .init = XAVS_init, |
|
344 |
+ .encode = XAVS_frame, |
|
345 |
+ .close = XAVS_close, |
|
346 |
+ .capabilities = CODEC_CAP_DELAY, |
|
347 |
+ .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE }, |
|
348 |
+ .long_name = NULL_IF_CONFIG_SMALL("libxavs - the Chinese Audio Video Standard Encoder"), |
|
349 |
+}; |
|
350 |
+ |
... | ... |
@@ -69,7 +69,7 @@ void av_register_all(void) |
69 | 69 |
REGISTER_DEMUXER (BINK, bink); |
70 | 70 |
REGISTER_DEMUXER (C93, c93); |
71 | 71 |
REGISTER_DEMUXER (CAF, caf); |
72 |
- REGISTER_DEMUXER (CAVSVIDEO, cavsvideo); |
|
72 |
+ REGISTER_MUXDEMUX (CAVSVIDEO, cavsvideo); |
|
73 | 73 |
REGISTER_DEMUXER (CDG, cdg); |
74 | 74 |
REGISTER_MUXER (CRC, crc); |
75 | 75 |
REGISTER_MUXDEMUX (DAUD, daud); |
... | ... |
@@ -981,6 +981,22 @@ AVOutputFormat h264_muxer = { |
981 | 981 |
}; |
982 | 982 |
#endif |
983 | 983 |
|
984 |
+#if CONFIG_CAVSVIDEO_MUXER |
|
985 |
+AVOutputFormat cavsvideo_muxer = { |
|
986 |
+ "cavsvideo", |
|
987 |
+ NULL_IF_CONFIG_SMALL("raw Chinese AVS video"), |
|
988 |
+ NULL, |
|
989 |
+ "cavs", |
|
990 |
+ 0, |
|
991 |
+ CODEC_ID_NONE, |
|
992 |
+ CODEC_ID_CAVS, |
|
993 |
+ NULL, |
|
994 |
+ raw_write_packet, |
|
995 |
+ .flags= AVFMT_NOTIMESTAMPS, |
|
996 |
+ .extensions = "avs", |
|
997 |
+}; |
|
998 |
+#endif |
|
999 |
+ |
|
984 | 1000 |
#if CONFIG_INGENIENT_DEMUXER |
985 | 1001 |
AVInputFormat ingenient_demuxer = { |
986 | 1002 |
"ingenient", |