diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2012-10-29 15:34:59 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-12-21 22:56:31 +0400 |
commit | 832fbb5aec6ec877ed9273a0b20520e3dc0b23b3 (patch) | |
tree | 26be956144a2fbe141ef9dd400796ac85c525913 /drivers/media/platform/coda.c | |
parent | 3f3f5c7f63dec5d6413075116cd6beee1e888d7b (diff) | |
download | linux-832fbb5aec6ec877ed9273a0b20520e3dc0b23b3.tar.xz |
[media] media: coda: Fix H.264 header alignment - v2
Length of H.264 headers is variable and thus it might not be
aligned for the coda to append the encoded frame. This causes
the first frame to overwrite part of the H.264 PPS.
In order to solve that, a filler NAL must be added between
the headers and the first frame to preserve alignment.
[mchehab@redhat.com: applied only v2 diff here, as v1 ended by mistakenly
being applied]
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform/coda.c')
-rw-r--r-- | drivers/media/platform/coda.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 8b7f5ac7fc11..2721f839852f 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -178,8 +178,9 @@ struct coda_ctx { int idx; }; -static u8 coda_filler_nal[] = { 0x00, 0x00, 0x00, 0x01, 0x0c, - 0xff, 0xff, 0xff, 0xff, 0xff}; +static const u8 coda_filler_nal[14] = { 0x00, 0x00, 0x00, 0x01, 0x0c, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80 }; +static const u8 coda_filler_size[8] = { 0, 7, 14, 13, 12, 11, 10, 9 }; static inline void coda_write(struct coda_dev *dev, u32 data, u32 reg) { @@ -949,19 +950,14 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_d static int coda_h264_padding(int size, char *p) { - int size_align = size & ~0x3; - int filler_size = ARRAY_SIZE(coda_filler_nal); int nal_size; int diff; - diff = size - size_align; + diff = size - (size & ~0x7); if (diff == 0) return 0; - nal_size = filler_size + 2 - diff; - if (nal_size > filler_size) - nal_size -= 4; - + nal_size = coda_filler_size[diff]; memcpy(p, coda_filler_nal, nal_size); /* Add rbsp stop bit and trailing at the end */ |