diff mbox

[FFmpeg-devel] avcodec/prores_kostya: increase bits usage when alpha is used

Message ID 20170625153848.18265-1-onemda@gmail.com
State Accepted
Commit 315f51128a95ca34ac3212c86b2a938330ba6b6e
Headers show

Commit Message

Paul B Mahol June 25, 2017, 3:38 p.m. UTC
Also fix undefined left shift of negative variable.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/proresenc_kostya.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Rostislav Pehlivanov June 25, 2017, 6:01 p.m. UTC | #1
On 25 June 2017 at 16:38, Paul B Mahol <onemda@gmail.com> wrote:

> Also fix undefined left shift of negative variable.
>
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/proresenc_kostya.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 090dfa5..25f7fcb 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -358,7 +358,7 @@ static inline void encode_vlc_codeword(PutBitContext
> *pb, unsigned codebook, int
>  }
>
>  #define GET_SIGN(x)  ((x) >> 31)
> -#define MAKE_CODE(x) (((x) << 1) ^ GET_SIGN(x))
> +#define MAKE_CODE(x) ((((x)) * 2) ^ GET_SIGN(x))
>
>  static void encode_dcs(PutBitContext *pb, int16_t *blocks,
>                         int blocks_per_slice, int scale)
> @@ -1206,6 +1206,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>                                             ctx->pictures_per_frame)
>                      break;
>              ctx->bits_per_mb   = ctx->profile_info->br_tab[i];
> +            if (ctx->alpha_bits)
> +                ctx->bits_per_mb *= 20;
>          } else if (ctx->bits_per_mb < 128) {
>              av_log(avctx, AV_LOG_ERROR, "too few bits per MB, please set
> at least 128\n");
>              return AVERROR_INVALIDDATA;
> --
> 2.9.3
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Makes sense, LGTM
diff mbox

Patch

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 090dfa5..25f7fcb 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -358,7 +358,7 @@  static inline void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int
 }
 
 #define GET_SIGN(x)  ((x) >> 31)
-#define MAKE_CODE(x) (((x) << 1) ^ GET_SIGN(x))
+#define MAKE_CODE(x) ((((x)) * 2) ^ GET_SIGN(x))
 
 static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int scale)
@@ -1206,6 +1206,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
                                            ctx->pictures_per_frame)
                     break;
             ctx->bits_per_mb   = ctx->profile_info->br_tab[i];
+            if (ctx->alpha_bits)
+                ctx->bits_per_mb *= 20;
         } else if (ctx->bits_per_mb < 128) {
             av_log(avctx, AV_LOG_ERROR, "too few bits per MB, please set at least 128\n");
             return AVERROR_INVALIDDATA;