Advertisement
Guest User

Untitled

a guest
Feb 7th, 2010
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.76 KB | None | 0 0
  1. --- 0.5/libavcodec/avcodec.h 2009-12-28 13:06:56.173795500 -0500
  2. +++ trunk/libavcodec/avcodec.h 2009-12-28 13:06:11.361232300 -0500
  3. @@ -499,10 +580,11 @@
  4. #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
  5. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
  6. #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
  7. #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
  8. #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
  9. +#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
  10.  
  11. /* Unsupported options :
  12. * Syntax Arithmetic coding (SAC)
  13. * Reference Picture Selection
  14. * Independent Segment Decoding */
  15. @@ -2330,10 +2488,87 @@
  16. * if no telecine is used ...
  17. *
  18. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
  19. */
  20. int ticks_per_frame;
  21. +
  22. + /**
  23. + * Hardware accelerator context.
  24. + * For some hardware accelerators, a global context needs to be
  25. + * provided by the user. In that case, this holds display-dependent
  26. + * data FFmpeg cannot instantiate itself. Please refer to the
  27. + * FFmpeg HW accelerator documentation to know how to fill this
  28. + * is. e.g. for VA API, this is a struct vaapi_context.
  29. + * - encoding: unused
  30. + * - decoding: Set by user
  31. + */
  32. + void *hwaccel_context;
  33. +
  34. + /**
  35. + * Chromaticity coordinates of the source primaries.
  36. + * - encoding: Set by user
  37. + * - decoding: Set by libavcodec
  38. + */
  39. + enum AVColorPrimaries color_primaries;
  40. +
  41. + /**
  42. + * Color Transfer Characteristic.
  43. + * - encoding: Set by user
  44. + * - decoding: Set by libavcodec
  45. + */
  46. + enum AVColorTransferCharacteristic color_trc;
  47. +
  48. + /**
  49. + * YUV colorspace type.
  50. + * - encoding: Set by user
  51. + * - decoding: Set by libavcodec
  52. + */
  53. + enum AVColorSpace colorspace;
  54. +
  55. + /**
  56. + * MPEG vs JPEG YUV range.
  57. + * - encoding: Set by user
  58. + * - decoding: Set by libavcodec
  59. + */
  60. + enum AVColorRange color_range;
  61. +
  62. + /**
  63. + * This defines the location of chroma samples.
  64. + * - encoding: Set by user
  65. + * - decoding: Set by libavcodec
  66. + */
  67. + enum AVChromaLocation chroma_sample_location;
  68. +
  69. + /**
  70. + * The codec may call this to execute several independent things.
  71. + * It will return only after finishing all tasks.
  72. + * The user may replace this with some multithreaded implementation,
  73. + * the default implementation will execute the parts serially.
  74. + * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
  75. + * @param c context passed also to func
  76. + * @param count the number of things to execute
  77. + * @param arg2 argument passed unchanged to func
  78. + * @param ret return values of executed functions, must have space for "count" values. May be NULL.
  79. + * @param func function that will be called count times, with jobnr from 0 to count-1.
  80. + * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
  81. + * two instances of func executing at the same time will have the same threadnr.
  82. + * @return always 0 currently, but code should handle a future improvement where when any call to func
  83. + * returns < 0 no further calls to func may be done and < 0 is returned.
  84. + * - encoding: Set by libavcodec, user can override.
  85. + * - decoding: Set by libavcodec, user can override.
  86. + */
  87. + int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
  88. +
  89. + /**
  90. + * explicit P-frame weighted prediction analysis method
  91. + * 0: off
  92. + * 1: fast blind weighting (one reference duplicate with -1 offset)
  93. + * 2: smart weighting (full fade detection analysis)
  94. + * - encoding: Set by user.
  95. + * - decoding: unused
  96. + */
  97. + int weighted_p_pred;
  98. } AVCodecContext;
  99.  
  100. /**
  101. * AVCodec.
  102. */
  103. --- 0.5/libavcodec/libx264.c 2009-12-28 13:06:55.305745800 -0500
  104. +++ trunk/libavcodec/libx264.c 2009-12-28 13:06:12.803314800 -0500
  105. @@ -25,83 +25,96 @@
  106. #include <stdio.h>
  107. #include <stdlib.h>
  108. #include <string.h>
  109.  
  110. typedef struct X264Context {
  111. - x264_param_t params;
  112. - x264_t *enc;
  113. - x264_picture_t pic;
  114. - AVFrame out_pic;
  115. + x264_param_t params;
  116. + x264_t *enc;
  117. + x264_picture_t pic;
  118. + uint8_t *sei;
  119. + int sei_size;
  120. + AVFrame out_pic;
  121. } X264Context;
  122.  
  123. -static void
  124. -X264_log(void *p, int level, const char *fmt, va_list args)
  125. +static void X264_log(void *p, int level, const char *fmt, va_list args)
  126. {
  127. static const int level_map[] = {
  128. [X264_LOG_ERROR] = AV_LOG_ERROR,
  129. [X264_LOG_WARNING] = AV_LOG_WARNING,
  130. [X264_LOG_INFO] = AV_LOG_INFO,
  131. [X264_LOG_DEBUG] = AV_LOG_DEBUG
  132. };
  133.  
  134. - if(level < 0 || level > X264_LOG_DEBUG)
  135. + if (level < 0 || level > X264_LOG_DEBUG)
  136. return;
  137.  
  138. av_vlog(p, level_map[level], fmt, args);
  139. }
  140.  
  141.  
  142. -static int
  143. -encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
  144. +static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size,
  145. + x264_nal_t *nals, int nnal, int skip_sei)
  146. {
  147. + X264Context *x4 = ctx->priv_data;
  148. uint8_t *p = buf;
  149. int i;
  150.  
  151. - for(i = 0; i < nnal; i++){
  152. - int s = x264_nal_encode(p, &size, 1, nals + i);
  153. - if(s < 0)
  154. - return -1;
  155. - p += s;
  156. + /* Write the SEI as part of the first frame. */
  157. + if (x4->sei_size > 0 && nnal > 0) {
  158. + memcpy(p, x4->sei, x4->sei_size);
  159. + p += x4->sei_size;
  160. + x4->sei_size = 0;
  161. + }
  162. +
  163. + for (i = 0; i < nnal; i++){
  164. + /* Don't put the SEI in extradata. */
  165. + if (skip_sei && nals[i].i_type == NAL_SEI) {
  166. + x4->sei_size = nals[i].i_payload;
  167. + x4->sei = av_malloc(x4->sei_size);
  168. + memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);
  169. + continue;
  170. + }
  171. + memcpy(p, nals[i].p_payload, nals[i].i_payload);
  172. + p += nals[i].i_payload;
  173. }
  174.  
  175. return p - buf;
  176. }
  177.  
  178. -static int
  179. -X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data)
  180. +static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
  181. + int bufsize, void *data)
  182. {
  183. X264Context *x4 = ctx->priv_data;
  184. AVFrame *frame = data;
  185. x264_nal_t *nal;
  186. int nnal, i;
  187. x264_picture_t pic_out;
  188.  
  189. - x4->pic.img.i_csp = X264_CSP_I420;
  190. + x4->pic.img.i_csp = X264_CSP_I420;
  191. x4->pic.img.i_plane = 3;
  192.  
  193. if (frame) {
  194. - for(i = 0; i < 3; i++){
  195. - x4->pic.img.plane[i] = frame->data[i];
  196. + for (i = 0; i < 3; i++) {
  197. + x4->pic.img.plane[i] = frame->data[i];
  198. x4->pic.img.i_stride[i] = frame->linesize[i];
  199. }
  200.  
  201. - x4->pic.i_pts = frame->pts;
  202. + x4->pic.i_pts = frame->pts;
  203. x4->pic.i_type = X264_TYPE_AUTO;
  204. }
  205.  
  206. - if(x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL,
  207. - &pic_out))
  208. + if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
  209. return -1;
  210.  
  211. - bufsize = encode_nals(buf, bufsize, nal, nnal);
  212. - if(bufsize < 0)
  213. + bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
  214. + if (bufsize < 0)
  215. return -1;
  216.  
  217. /* FIXME: dts */
  218. x4->out_pic.pts = pic_out.i_pts;
  219.  
  220. - switch(pic_out.i_type){
  221. + switch (pic_out.i_type) {
  222. case X264_TYPE_IDR:
  223. case X264_TYPE_I:
  224. x4->out_pic.pict_type = FF_I_TYPE;
  225. break;
  226. case X264_TYPE_P:
  227. @@ -112,193 +125,192 @@
  228. x4->out_pic.pict_type = FF_B_TYPE;
  229. break;
  230. }
  231.  
  232. x4->out_pic.key_frame = pic_out.i_type == X264_TYPE_IDR;
  233. - x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
  234. + x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
  235.  
  236. return bufsize;
  237. }
  238.  
  239. -static av_cold int
  240. -X264_close(AVCodecContext *avctx)
  241. +static av_cold int X264_close(AVCodecContext *avctx)
  242. {
  243. X264Context *x4 = avctx->priv_data;
  244.  
  245. av_freep(&avctx->extradata);
  246. + av_free(x4->sei);
  247.  
  248. - if(x4->enc)
  249. + if (x4->enc)
  250. x264_encoder_close(x4->enc);
  251.  
  252. return 0;
  253. }
  254.  
  255. -static av_cold int
  256. -X264_init(AVCodecContext *avctx)
  257. +static av_cold int X264_init(AVCodecContext *avctx)
  258. {
  259. X264Context *x4 = avctx->priv_data;
  260.  
  261. + x4->sei_size = 0;
  262. x264_param_default(&x4->params);
  263.  
  264. - x4->params.pf_log = X264_log;
  265. - x4->params.p_log_private = avctx;
  266. + x4->params.pf_log = X264_log;
  267. + x4->params.p_log_private = avctx;
  268.  
  269. - x4->params.i_keyint_max = avctx->gop_size;
  270. - x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
  271. + x4->params.i_keyint_max = avctx->gop_size;
  272. + x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
  273. x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
  274. - x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
  275. - x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
  276. - if(avctx->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1;
  277. - else{
  278. - if(avctx->crf){
  279. - x4->params.rc.i_rc_method = X264_RC_CRF;
  280. + x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
  281. + x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
  282. + if (avctx->flags & CODEC_FLAG_PASS2) {
  283. + x4->params.rc.b_stat_read = 1;
  284. + } else {
  285. + if (avctx->crf) {
  286. + x4->params.rc.i_rc_method = X264_RC_CRF;
  287. x4->params.rc.f_rf_constant = avctx->crf;
  288. - }else if(avctx->cqp > -1){
  289. - x4->params.rc.i_rc_method = X264_RC_CQP;
  290. + } else if (avctx->cqp > -1) {
  291. + x4->params.rc.i_rc_method = X264_RC_CQP;
  292. x4->params.rc.i_qp_constant = avctx->cqp;
  293. }
  294. }
  295.  
  296. // if neither crf nor cqp modes are selected we have to enable the RC
  297. // we do it this way because we cannot check if the bitrate has been set
  298. - if(!(avctx->crf || (avctx->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR;
  299. + if (!(avctx->crf || (avctx->cqp > -1)))
  300. + x4->params.rc.i_rc_method = X264_RC_ABR;
  301.  
  302. - x4->params.i_bframe = avctx->max_b_frames;
  303. - x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
  304. + x4->params.i_bframe = avctx->max_b_frames;
  305. + x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
  306. x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
  307. - x4->params.i_bframe_bias = avctx->bframebias;
  308. - x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
  309. - avctx->has_b_frames= avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
  310. + x4->params.i_bframe_bias = avctx->bframebias;
  311. + x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
  312. + avctx->has_b_frames = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
  313.  
  314. x4->params.i_keyint_min = avctx->keyint_min;
  315. - if(x4->params.i_keyint_min > x4->params.i_keyint_max)
  316. + if (x4->params.i_keyint_min > x4->params.i_keyint_max)
  317. x4->params.i_keyint_min = x4->params.i_keyint_max;
  318.  
  319. - x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
  320. + x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
  321.  
  322. - x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
  323. + x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
  324. x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
  325. - x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
  326. + x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
  327.  
  328. - x4->params.rc.i_qp_min = avctx->qmin;
  329. - x4->params.rc.i_qp_max = avctx->qmax;
  330. - x4->params.rc.i_qp_step = avctx->max_qdiff;
  331. + x4->params.rc.i_qp_min = avctx->qmin;
  332. + x4->params.rc.i_qp_max = avctx->qmax;
  333. + x4->params.rc.i_qp_step = avctx->max_qdiff;
  334.  
  335. - x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
  336. - x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
  337. + x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
  338. + x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
  339. x4->params.rc.f_complexity_blur = avctx->complexityblur;
  340.  
  341. - x4->params.i_frame_reference = avctx->refs;
  342. + x4->params.i_frame_reference = avctx->refs;
  343.  
  344. - x4->params.i_width = avctx->width;
  345. - x4->params.i_height = avctx->height;
  346. - x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
  347. - x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
  348. - x4->params.i_fps_num = avctx->time_base.den;
  349. - x4->params.i_fps_den = avctx->time_base.num;
  350. -
  351. - x4->params.analyse.inter = 0;
  352. - if(avctx->partitions){
  353. - if(avctx->partitions & X264_PART_I4X4)
  354. + x4->params.i_width = avctx->width;
  355. + x4->params.i_height = avctx->height;
  356. + x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
  357. + x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
  358. + x4->params.i_fps_num = avctx->time_base.den;
  359. + x4->params.i_fps_den = avctx->time_base.num;
  360. +
  361. + x4->params.analyse.inter = 0;
  362. + if (avctx->partitions) {
  363. + if (avctx->partitions & X264_PART_I4X4)
  364. x4->params.analyse.inter |= X264_ANALYSE_I4x4;
  365. - if(avctx->partitions & X264_PART_I8X8)
  366. + if (avctx->partitions & X264_PART_I8X8)
  367. x4->params.analyse.inter |= X264_ANALYSE_I8x8;
  368. - if(avctx->partitions & X264_PART_P8X8)
  369. + if (avctx->partitions & X264_PART_P8X8)
  370. x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;
  371. - if(avctx->partitions & X264_PART_P4X4)
  372. + if (avctx->partitions & X264_PART_P4X4)
  373. x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;
  374. - if(avctx->partitions & X264_PART_B8X8)
  375. + if (avctx->partitions & X264_PART_B8X8)
  376. x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;
  377. }
  378.  
  379. - x4->params.analyse.i_direct_mv_pred = avctx->directpred;
  380. + x4->params.analyse.i_direct_mv_pred = avctx->directpred;
  381.  
  382. x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
  383. + x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred;
  384.  
  385. - if(avctx->me_method == ME_EPZS)
  386. + if (avctx->me_method == ME_EPZS)
  387. x4->params.analyse.i_me_method = X264_ME_DIA;
  388. - else if(avctx->me_method == ME_HEX)
  389. + else if (avctx->me_method == ME_HEX)
  390. x4->params.analyse.i_me_method = X264_ME_HEX;
  391. - else if(avctx->me_method == ME_UMH)
  392. + else if (avctx->me_method == ME_UMH)
  393. x4->params.analyse.i_me_method = X264_ME_UMH;
  394. - else if(avctx->me_method == ME_FULL)
  395. + else if (avctx->me_method == ME_FULL)
  396. x4->params.analyse.i_me_method = X264_ME_ESA;
  397. - else if(avctx->me_method == ME_TESA)
  398. + else if (avctx->me_method == ME_TESA)
  399. x4->params.analyse.i_me_method = X264_ME_TESA;
  400. else x4->params.analyse.i_me_method = X264_ME_HEX;
  401.  
  402. - x4->params.analyse.i_me_range = avctx->me_range;
  403. - x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
  404. + x4->params.analyse.i_me_range = avctx->me_range;
  405. + x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
  406.  
  407. - x4->params.analyse.b_mixed_references =
  408. - avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
  409. - x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
  410. - x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT;
  411. - x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
  412. + x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
  413. + x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
  414. + x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT;
  415. + x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
  416.  
  417. - x4->params.analyse.i_trellis = avctx->trellis;
  418. - x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
  419. + x4->params.analyse.i_trellis = avctx->trellis;
  420. + x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
  421.  
  422. - if(avctx->level > 0) x4->params.i_level_idc = avctx->level;
  423. + if (avctx->level > 0)
  424. + x4->params.i_level_idc = avctx->level;
  425.  
  426. x4->params.rc.f_rate_tolerance =
  427. (float)avctx->bit_rate_tolerance/avctx->bit_rate;
  428.  
  429. - if((avctx->rc_buffer_size != 0) &&
  430. - (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)){
  431. + if ((avctx->rc_buffer_size != 0) &&
  432. + (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
  433. x4->params.rc.f_vbv_buffer_init =
  434. - (float)avctx->rc_initial_buffer_occupancy/avctx->rc_buffer_size;
  435. - }
  436. - else x4->params.rc.f_vbv_buffer_init = 0.9;
  437. -
  438. - x4->params.rc.f_ip_factor = 1/fabs(avctx->i_quant_factor);
  439. - x4->params.rc.f_pb_factor = avctx->b_quant_factor;
  440. + (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
  441. + } else
  442. + x4->params.rc.f_vbv_buffer_init = 0.9;
  443. +
  444. + x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
  445. + x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
  446. + x4->params.rc.f_pb_factor = avctx->b_quant_factor;
  447. x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
  448.  
  449. x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
  450. - x4->params.i_log_level = X264_LOG_DEBUG;
  451. + x4->params.i_log_level = X264_LOG_DEBUG;
  452.  
  453. - x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD;
  454. + x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD;
  455.  
  456. - x4->params.i_threads = avctx->thread_count;
  457. + x4->params.i_threads = avctx->thread_count;
  458.  
  459. - x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
  460. + x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
  461.  
  462. - if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
  463. + if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
  464. x4->params.b_repeat_headers = 0;
  465. - }
  466.  
  467. x4->enc = x264_encoder_open(&x4->params);
  468. - if(!x4->enc)
  469. + if (!x4->enc)
  470. return -1;
  471.  
  472. avctx->coded_frame = &x4->out_pic;
  473.  
  474. - if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
  475. + if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
  476. x264_nal_t *nal;
  477. - int nnal, i, s = 0;
  478. -
  479. - x264_encoder_headers(x4->enc, &nal, &nnal);
  480. + int nnal, s;
  481.  
  482. - /* 5 bytes NAL header + worst case escaping */
  483. - for(i = 0; i < nnal; i++)
  484. - s += 5 + nal[i].i_payload * 4 / 3;
  485. + s = x264_encoder_headers(x4->enc, &nal, &nnal);
  486.  
  487. - avctx->extradata = av_malloc(s);
  488. - avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
  489. + avctx->extradata = av_malloc(s);
  490. + avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
  491. }
  492.  
  493. return 0;
  494. }
  495.  
  496. AVCodec libx264_encoder = {
  497. - .name = "libx264",
  498. - .type = CODEC_TYPE_VIDEO,
  499. - .id = CODEC_ID_H264,
  500. + .name = "libx264",
  501. + .type = CODEC_TYPE_VIDEO,
  502. + .id = CODEC_ID_H264,
  503. .priv_data_size = sizeof(X264Context),
  504. - .init = X264_init,
  505. - .encode = X264_frame,
  506. - .close = X264_close,
  507. - .capabilities = CODEC_CAP_DELAY,
  508. - .pix_fmts = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
  509. - .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
  510. + .init = X264_init,
  511. + .encode = X264_frame,
  512. + .close = X264_close,
  513. + .capabilities = CODEC_CAP_DELAY,
  514. + .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
  515. + .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
  516. };
  517. --- 0.5/configure 2009-12-28 13:07:08.323490400 -0500
  518. +++ trunk/configure 2009-12-28 13:06:25.307030000 -0500
  519. @@ -2003,15 +2382,15 @@
  520. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
  521. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  522. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  523. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  524. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  525. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  526. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  527. -enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
  528. - { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  529. - die "ERROR: libx264 version must be >= 0.65."; }
  530. +enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
  531. + { check_cpp_condition x264.h "X264_BUILD >= 79" ||
  532. + die "ERROR: libx264 version must be >= 0.79."; }
  533. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  534. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  535.  
  536. # libdc1394 check
  537. if enabled libdc1394; then
  538.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement