[06/11] flvenc: Write proper cropping for VP6 even if there's no extradata

Message ID 1381320210-79941-6-git-send-email-martin@martin.st
State Committed
Commit e6ed8668597cfea25dfb350a9b4df7fb2efc1d90
Headers show

Commit Message

Martin Storsjö Oct. 9, 2013, 12:03 p.m.
This keeps cropping when remuxing from F4V to FLV.
---
 libavformat/flvenc.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Martin Storsjö Oct. 9, 2013, 12:23 p.m. | #1
On Wed, 9 Oct 2013, Martin Storsjö wrote:

> This keeps cropping when remuxing from F4V to FLV.
> ---
> libavformat/flvenc.c |   10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)

OK'd by Kostya on irc.

// Martin

Patch

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 1ec9c2e..1448c5d 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -527,9 +527,13 @@  static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         avio_wb32(pb, data_size + 11);
     } else {
         avio_w8(pb,flags);
-        if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A)
-            avio_w8(pb, enc->extradata_size ? enc->extradata[0] : 0);
-        else if (enc->codec_id == AV_CODEC_ID_AAC)
+        if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A) {
+            if (enc->extradata_size)
+                avio_w8(pb, enc->extradata[0]);
+            else
+                avio_w8(pb, ((FFALIGN(enc->width,  16) - enc->width) << 4) |
+                             (FFALIGN(enc->height, 16) - enc->height));
+        } else if (enc->codec_id == AV_CODEC_ID_AAC)
             avio_w8(pb, 1); // AAC raw
         else if (enc->codec_id == AV_CODEC_ID_H264) {
             avio_w8(pb, 1); // AVC NALU