[MPlayer-cvslog] r31269 - in branches/1.0rc3: configure libmpcodecs/ve_x264.c libmpcodecs/ve_x264.h

siretart subversion at mplayerhq.hu
Sat May 29 22:16:39 CEST 2010


Author: siretart
Date: Sat May 29 22:16:38 2010
New Revision: 31269

Log:
backport updated x264 to allow compilation with newer libx264 versions

tested against libx264-85

This backports changes r29108,29138,29150,29157-29160,29220,29222-29223,29225-29228,29369-29370,29447,29455,29626,30060-30062,30175,30199,30222,31049,31054,31057,31209-31210

Added:
   branches/1.0rc3/libmpcodecs/ve_x264.h
      - copied unchanged from r31268, trunk/libmpcodecs/ve_x264.h
Modified:
   branches/1.0rc3/configure   (contents, props changed)
   branches/1.0rc3/libmpcodecs/ve_x264.c   (contents, props changed)

Modified: branches/1.0rc3/configure
==============================================================================
--- branches/1.0rc3/configure	Sat May 29 18:34:01 2010	(r31268)
+++ branches/1.0rc3/configure	Sat May 29 22:16:38 2010	(r31269)
@@ -7072,8 +7072,8 @@ if test "$_x264" = auto ; then
   cat > $TMPC << EOF
 #include <inttypes.h>
 #include <x264.h>
-#if X264_BUILD < 65
-#error We do not support old versions of x264. Get the latest from SVN.
+#if X264_BUILD < 83
+#error We do not support old versions of x264. Get the latest from git.
 #endif
 int main(void) { x264_encoder_open((void*)0); return 0; }
 EOF

Modified: branches/1.0rc3/libmpcodecs/ve_x264.c
==============================================================================
--- branches/1.0rc3/libmpcodecs/ve_x264.c	Sat May 29 18:34:01 2010	(r31268)
+++ branches/1.0rc3/libmpcodecs/ve_x264.c	Sat May 29 22:16:38 2010	(r31269)
@@ -45,6 +45,7 @@
 #include "img_format.h"
 #include "mp_image.h"
 #include "vf.h"
+#include "ve_x264.h"
 
 #include <x264.h>
 
@@ -59,20 +60,6 @@ static int turbo = 0;
 static x264_param_t param;
 static int parse_error = 0;
 
-static int encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal){
-    uint8_t *p = buf;
-    int i;
-
-    for(i = 0; i < nnal; i++){
-        int s = x264_nal_encode(p, &size, 1, nals + i);
-        if(s < 0)
-            return -1;
-        p += s;
-    }
-
-    return p - buf;
-}
-
 static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts);
 static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in);
 
@@ -158,13 +145,14 @@ static int config(struct vf_instance_s* 
     mod->mux->bih->biHeight = height;
     mod->mux->bih->biSizeImage = width * height * 3;
     mod->mux->aspect = (float)d_width/d_height;
-    
+
     // make sure param is initialized
     x264enc_set_param(NULL, "");
     param.i_width = width;
     param.i_height = height;
     param.i_fps_num = mod->mux->h.dwRate;
     param.i_fps_den = mod->mux->h.dwScale;
+    param.b_vfr_input = 0;
     param.vui.i_sar_width = d_width*height;
     param.vui.i_sar_height = d_height*width;
 
@@ -181,7 +169,7 @@ static int config(struct vf_instance_s* 
         mp_msg(MSGT_MENCODER, MSGL_ERR, "Wrong colorspace.\n");
         return 0;
     }
-    
+
     mod->x264 = x264_encoder_open(&param);
     if(!mod->x264) {
         mp_msg(MSGT_MENCODER, MSGL_ERR, "x264_encoder_open failed.\n");
@@ -189,29 +177,21 @@ static int config(struct vf_instance_s* 
     }
 
     if(!param.b_repeat_headers){
-        uint8_t *extradata;
         x264_nal_t *nal;
-        int extradata_size, nnal, i, s = 0;
-
-        x264_encoder_headers(mod->x264, &nal, &nnal);
-
-        /* 5 bytes NAL header + worst case escaping */
-        for(i = 0; i < nnal; i++)
-            s += 5 + nal[i].i_payload * 4 / 3;
+        int extradata_size, nnal;
 
-        extradata = malloc(s);
-        extradata_size = encode_nals(extradata, s, nal, nnal);
+        extradata_size = x264_encoder_headers(mod->x264, &nal, &nnal);
 
         mod->mux->bih= realloc(mod->mux->bih, sizeof(BITMAPINFOHEADER) + extradata_size);
-        memcpy(mod->mux->bih + 1, extradata, extradata_size);
+        memcpy(mod->mux->bih + 1, nal->p_payload, extradata_size);
         mod->mux->bih->biSize= sizeof(BITMAPINFOHEADER) + extradata_size;
     }
-    
-    if (param.i_bframe > 1 && param.b_bframe_pyramid)
+
+    if (param.i_bframe > 1 && param.i_bframe_pyramid)
         mod->mux->decoder_delay = 2;
     else
         mod->mux->decoder_delay = param.i_bframe ? 1 : 0;
-    
+
     return 1;
 }
 
@@ -220,8 +200,8 @@ static int control(struct vf_instance_s*
     h264_module_t *mod=(h264_module_t*)vf->priv;
     switch(request){
         case VFCTRL_FLUSH_FRAMES:
-            if(param.i_bframe)
-                while(encode_frame(vf, NULL) > 0);
+            while (x264_encoder_delayed_frames(mod->x264) > 0)
+                encode_frame(vf, NULL);
             return CONTROL_TRUE;
         default:
             return CONTROL_UNKNOWN;
@@ -251,7 +231,7 @@ static int put_image(struct vf_instance_
 {
     h264_module_t *mod=(h264_module_t*)vf->priv;
     int i;
-    
+
     memset(&mod->pic, 0, sizeof(x264_picture_t));
     mod->pic.img.i_csp=param.i_csp;
     mod->pic.img.i_plane=3;
@@ -271,24 +251,18 @@ static int encode_frame(struct vf_instan
     x264_picture_t pic_out;
     x264_nal_t *nal;
     int i_nal;
-    int i_size = 0;
-    int i;
+    int i_size;
 
-    if(x264_encoder_encode(mod->x264, &nal, &i_nal, pic_in, &pic_out) < 0) {
+    i_size = x264_encoder_encode(mod->x264, &nal, &i_nal, pic_in, &pic_out);
+
+    if(i_size<0) {
         mp_msg(MSGT_MENCODER, MSGL_ERR, "x264_encoder_encode failed\n");
         return -1;
     }
-    
-    for(i=0; i < i_nal; i++) {
-        int i_data = mod->mux->buffer_size - i_size;
-        i_size += x264_nal_encode(mod->mux->buffer + i_size, &i_data, 1, &nal[i]);
-    }
     if(i_size>0) {
-        int keyframe = (pic_out.i_type == X264_TYPE_IDR) ||
-                       (pic_out.i_type == X264_TYPE_I
-                        && param.i_frame_reference == 1
-                        && !param.i_bframe);
-        muxer_write_chunk(mod->mux, i_size, keyframe?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
+        int keyframe = pic_out.b_keyframe;
+        memcpy(mod->mux->buffer, nal->p_payload, i_size);
+        muxer_write_chunk(mod->mux, i_size, keyframe?AVIIF_KEYFRAME:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
     }
     else
         ++mod->mux->encoder_delay;


More information about the MPlayer-cvslog mailing list