diff mbox

[FFmpeg-devel,1/5] avcodec/utvideodec: Move bitstream end check out of inner loop

Message ID 20170627194735.27533-1-michael@niedermayer.cc
State Accepted
Commit 1835c5e7a4fd3a1e7c8a51ed410cecbfe6804ade
Headers show

Commit Message

Michael Niedermayer June 27, 2017, 7:47 p.m. UTC
This is not needed when the buffer is large enough for the worst case of a line

2% faster vlc reading

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/utvideodec.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Comments

Michael Niedermayer June 27, 2017, 8:01 p.m. UTC | #1
On Tue, Jun 27, 2017 at 09:47:31PM +0200, Michael Niedermayer wrote:

"Summary email is empty, skipping it"

somehow the summary mail for the thread was lost ...

it basically said thats a bunch of trivial optimizations surrounding
the vlc reader loop.


[...]
Paul B Mahol June 27, 2017, 8:51 p.m. UTC | #2
On 6/27/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> On Tue, Jun 27, 2017 at 09:47:31PM +0200, Michael Niedermayer wrote:
>
> "Summary email is empty, skipping it"
>
> somehow the summary mail for the thread was lost ...
>
> it basically said thats a bunch of trivial optimizations surrounding
> the vlc reader loop.

libavcodec/utvideodec.c: In function ***decode_plane10***:
libavcodec/utvideodec.c:193:27: warning: passing argument 2 of
***c->bdsp.bswap_buf*** from incompatible pointer type
[-Wincompatible-pointer-types]
src + slice_data_start + c->slices * 4,
^~~
libavcodec/utvideodec.c:193:27: note: expected ***const uint32_t *
{aka const unsigned int *}*** but argument is of type ***const uint8_t
* {aka const unsigned char *}***
libavcodec/utvideodec.c: In function ***decode_plane***:
libavcodec/utvideodec.c:298:27: warning: passing argument 2 of
***c->bdsp.bswap_buf*** from incompatible pointer type
[-Wincompatible-pointer-types]
src + slice_data_start + c->slices * 4,
^~~
libavcodec/utvideodec.c:298:27: note: expected ***const uint32_t *
{aka const unsigned int *}*** but argument is of type ***const uint8_t
* {aka const unsigned char *}***
Paul B Mahol June 27, 2017, 8:52 p.m. UTC | #3
On 6/27/17, Paul B Mahol <onemda@gmail.com> wrote:
> On 6/27/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
>> On Tue, Jun 27, 2017 at 09:47:31PM +0200, Michael Niedermayer wrote:
>>
>> "Summary email is empty, skipping it"
>>
>> somehow the summary mail for the thread was lost ...
>>
>> it basically said thats a bunch of trivial optimizations surrounding
>> the vlc reader loop.
>
> libavcodec/utvideodec.c: In function ***decode_plane10***:
> libavcodec/utvideodec.c:193:27: warning: passing argument 2 of
> ***c->bdsp.bswap_buf*** from incompatible pointer type
> [-Wincompatible-pointer-types]
> src + slice_data_start + c->slices * 4,
> ^~~
> libavcodec/utvideodec.c:193:27: note: expected ***const uint32_t *
> {aka const unsigned int *}*** but argument is of type ***const uint8_t
> * {aka const unsigned char *}***
> libavcodec/utvideodec.c: In function ***decode_plane***:
> libavcodec/utvideodec.c:298:27: warning: passing argument 2 of
> ***c->bdsp.bswap_buf*** from incompatible pointer type
> [-Wincompatible-pointer-types]
> src + slice_data_start + c->slices * 4,
> ^~~
> libavcodec/utvideodec.c:298:27: note: expected ***const uint32_t *
> {aka const unsigned int *}*** but argument is of type ***const uint8_t
> * {aka const unsigned char *}***
>

Except this, patchset LGTM.
Michael Niedermayer June 28, 2017, 12:08 p.m. UTC | #4
On Tue, Jun 27, 2017 at 10:52:42PM +0200, Paul B Mahol wrote:
> On 6/27/17, Paul B Mahol <onemda@gmail.com> wrote:
> > On 6/27/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> >> On Tue, Jun 27, 2017 at 09:47:31PM +0200, Michael Niedermayer wrote:
> >>
> >> "Summary email is empty, skipping it"
> >>
> >> somehow the summary mail for the thread was lost ...
> >>
> >> it basically said thats a bunch of trivial optimizations surrounding
> >> the vlc reader loop.
> >
> > libavcodec/utvideodec.c: In function ***decode_plane10***:
> > libavcodec/utvideodec.c:193:27: warning: passing argument 2 of
> > ***c->bdsp.bswap_buf*** from incompatible pointer type
> > [-Wincompatible-pointer-types]
> > src + slice_data_start + c->slices * 4,
> > ^~~
> > libavcodec/utvideodec.c:193:27: note: expected ***const uint32_t *
> > {aka const unsigned int *}*** but argument is of type ***const uint8_t
> > * {aka const unsigned char *}***
> > libavcodec/utvideodec.c: In function ***decode_plane***:
> > libavcodec/utvideodec.c:298:27: warning: passing argument 2 of
> > ***c->bdsp.bswap_buf*** from incompatible pointer type
> > [-Wincompatible-pointer-types]
> > src + slice_data_start + c->slices * 4,
> > ^~~
> > libavcodec/utvideodec.c:298:27: note: expected ***const uint32_t *
> > {aka const unsigned int *}*** but argument is of type ***const uint8_t
> > * {aka const unsigned char *}***
> >
> 
> Except this, patchset LGTM.

fixed, applied

thx

[...]
--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
diff mbox

Patch

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 44841aaa65..815b71cfb6 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -196,11 +196,6 @@  static int decode_plane10(UtvideoContext *c, int plane_no,
         prev = 0x200;
         for (j = sstart; j < send; j++) {
             for (i = 0; i < width * step; i += step) {
-                if (get_bits_left(&gb) <= 0) {
-                    av_log(c->avctx, AV_LOG_ERROR,
-                           "Slice decoding ran out of bits\n");
-                    goto fail;
-                }
                 pix = get_vlc2(&gb, vlc.table, vlc.bits, 3);
                 if (pix < 0) {
                     av_log(c->avctx, AV_LOG_ERROR, "Decoding error\n");
@@ -214,6 +209,11 @@  static int decode_plane10(UtvideoContext *c, int plane_no,
                 dest[i] = pix;
             }
             dest += stride;
+            if (get_bits_left(&gb) < 0) {
+                av_log(c->avctx, AV_LOG_ERROR,
+                        "Slice decoding ran out of bits\n");
+                goto fail;
+            }
         }
         if (get_bits_left(&gb) > 32)
             av_log(c->avctx, AV_LOG_WARNING,
@@ -302,11 +302,6 @@  static int decode_plane(UtvideoContext *c, int plane_no,
         prev = 0x80;
         for (j = sstart; j < send; j++) {
             for (i = 0; i < width * step; i += step) {
-                if (get_bits_left(&gb) <= 0) {
-                    av_log(c->avctx, AV_LOG_ERROR,
-                           "Slice decoding ran out of bits\n");
-                    goto fail;
-                }
                 pix = get_vlc2(&gb, vlc.table, vlc.bits, 3);
                 if (pix < 0) {
                     av_log(c->avctx, AV_LOG_ERROR, "Decoding error\n");
@@ -318,6 +313,11 @@  static int decode_plane(UtvideoContext *c, int plane_no,
                 }
                 dest[i] = pix;
             }
+            if (get_bits_left(&gb) < 0) {
+                av_log(c->avctx, AV_LOG_ERROR,
+                        "Slice decoding ran out of bits\n");
+                goto fail;
+            }
             dest += stride;
         }
         if (get_bits_left(&gb) > 32)
@@ -610,6 +610,8 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
 
     c->frame_pred = (c->frame_info >> 8) & 3;
 
+    max_slice_size += 4*avctx->width;
+
     av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
                    max_slice_size + AV_INPUT_BUFFER_PADDING_SIZE);