[MPlayer-dev-eng] [RFC] update to latest x264 API

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed Sep 23 13:26:53 CEST 2009


Hello,
this is untested and lacks a configure part to check that we have a
sufficiently new x264 version.
But maybe someone who runs on latest x264 can check if it works (you
have a sufficiently new version if it currently does not compile because
x264_nal_encode does not exist).
-------------- next part --------------
Index: libmpcodecs/ve_x264.c
===================================================================
--- libmpcodecs/ve_x264.c	(revision 29701)
+++ libmpcodecs/ve_x264.c	(working copy)
@@ -64,10 +64,8 @@
     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;
+        memcpy(p, nals[i].p_payload, nals[i].i_payload);
+        p += nals[i].i_payload;
     }
 
     return p - buf;
@@ -191,14 +189,10 @@
     if(!param.b_repeat_headers){
         uint8_t *extradata;
         x264_nal_t *nal;
-        int extradata_size, nnal, i, s = 0;
+        int extradata_size, nnal, s;
 
-        x264_encoder_headers(mod->x264, &nal, &nnal);
+        s = 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;
-
         extradata = malloc(s);
         extradata_size = encode_nals(extradata, s, nal, nnal);
 
@@ -281,10 +275,7 @@
         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]);
-    }
+    i_size = encode_nals(mod->mux->buffer, mod->mux->buffer_size, nal, i_nal);
     if(i_size>0) {
         int keyframe = (pic_out.i_type == X264_TYPE_IDR) ||
                        (pic_out.i_type == X264_TYPE_I


More information about the MPlayer-dev-eng mailing list