changeset 29662:fb0202969d92

sync to x264-r1260 (which changed api)
author lorenm
date Wed, 23 Sep 2009 12:01:04 +0000
parents 6e5bf32db9ff
children 18b540567d56
files configure libmpcodecs/ve_x264.c
diffstat 2 files changed, 10 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Wed Sep 23 09:12:19 2009 +0000
+++ b/configure	Wed Sep 23 12:01:04 2009 +0000
@@ -7240,8 +7240,8 @@
   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 < 76
+#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
--- a/libmpcodecs/ve_x264.c	Wed Sep 23 09:12:19 2009 +0000
+++ b/libmpcodecs/ve_x264.c	Wed Sep 23 12:01:04 2009 +0000
@@ -59,20 +59,6 @@
 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);
 
@@ -189,21 +175,13 @@
     }
 
     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);
+        int extradata_size, 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);
+        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;
     }
 
@@ -273,23 +251,20 @@
     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);
+        memcpy(mod->mux->buffer, nal->p_payload, i_size);
         muxer_write_chunk(mod->mux, i_size, keyframe?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
     }
     else