[FFmpeg-devel,1/2] avcodec/vc2enc: do not write an End Sequence after the first field of field-separated pictures

Submitted by James Darnley on Feb. 23, 2018, 5:33 p.m.

Details

Message ID 20180223173345.2105-2-jdarnley@obe.tv
State New
Headers show

Commit Message

James Darnley Feb. 23, 2018, 5:33 p.m.
A lax or tolerant decoder may support an End Sequence between fields of the same
frame but the spec. says this is not allowed.

2012 spec. 10.3.2, 2017 spec. 10.4.3:
Where pictures are fields, a sequence shall comprise a whole number of
frames (i.e., an even number of fields) and shall begin and end with a
whole frame/field-pair.
---
 libavcodec/vc2enc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index b7adcd3d36..9a5a4765c8 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -988,7 +988,13 @@  static int encode_frame(VC2EncContext *s, AVPacket *avpkt, const AVFrame *frame,
     encode_slices(s);
 
     /* End sequence */
-    encode_parse_info(s, DIRAC_PCODE_END_SEQ);
+    /* 2012 spec. 10.3.2, 2017 spec. 10.4.3:
+     * Where pictures are fields, a sequence shall comprise a whole number of
+     * frames (i.e., an even number of fields) and shall begin and end with a
+     * whole frame/field-pair. */
+    if (field != 1) {
+        encode_parse_info(s, DIRAC_PCODE_END_SEQ);
+    }
 
     return 0;
 }