[x264-devel] Fix frame-packing==5 with some decoders

Tal Aloni git at videolan.org
Sun Jul 20 11:58:28 CEST 2014


x264 | branch: master | Tal Aloni <tal.aloni.il at gmail.com> | Tue Jun 17 15:10:56 2014 -0700| [92fdb43dd47fbc3368d9d9c7ad940fbe03657bd3] | committer: Fiona Glaser

Fix frame-packing==5 with some decoders

The spec mandates that frame-packing==5 requires the SEI on every frame that
begins a view sequence (i.e. the input frames L0-R0-L1-R1 have 4 view sequences,
but if reordered by the encoder to L0-L1-R0-R1 there are now 2 view sequences).
For simplicity, we write the SEI on every frame.

This fixes frame-packing==5 3D playback on some decoders (PlayStation 3, Sony
W8 series, possibly others).

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=92fdb43dd47fbc3368d9d9c7ad940fbe03657bd3
---

 encoder/encoder.c |   16 ++++++++--------
 encoder/set.c     |    4 +++-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index fad8b3d..e484046 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -3539,15 +3539,15 @@ int     x264_encoder_encode( x264_t *h,
                 return -1;
             overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
         }
+    }
 
-        if( h->param.i_frame_packing >= 0 )
-        {
-            x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
-            x264_sei_frame_packing_write( h, &h->out.bs );
-            if( x264_nal_end( h ) )
-                return -1;
-            overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
-        }
+    if( h->param.i_frame_packing >= 0 && (h->fenc->b_keyframe || h->param.i_frame_packing == 5) )
+    {
+        x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
+        x264_sei_frame_packing_write( h, &h->out.bs );
+        if( x264_nal_end( h ) )
+            return -1;
+        overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
     }
 
     /* generate sei pic timing */
diff --git a/encoder/set.c b/encoder/set.c
index 6b0881b..bada400 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -675,7 +675,9 @@ void x264_sei_frame_packing_write( x264_t *h, bs_t *s )
         bs_write( &q, 4, 0 );                     // frame1_grid_position_y
     }
     bs_write( &q, 8, 0 );                         // frame_packing_arrangement_reserved_byte
-    bs_write_ue( &q, 1 );                         // frame_packing_arrangement_repetition_period
+    // "frame_packing_arrangement_repetition_period equal to 1 specifies that the frame packing arrangement SEI message persists in output"
+    // for (i_frame_packing == 5) this will undermine current_frame_is_frame0_flag which must alternate every view sequence
+    bs_write_ue( &q, h->param.i_frame_packing != 5 ); // frame_packing_arrangement_repetition_period
     bs_write1( &q, 0 );                           // frame_packing_arrangement_extension_flag
 
     bs_align_10( &q );



More information about the x264-devel mailing list