Guest User

Untitled

a guest
Sep 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.73 KB | None | 0 0
  1. diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
  2. index ef6a614..6896087 100644
  3. --- a/libavcodec/utvideoenc.c
  4. +++ b/libavcodec/utvideoenc.c
  5. @@ -473,6 +473,8 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
  6.  
  7.      uint32_t offset = 0, slice_len = 0;
  8.      int      i, sstart, send = 0;
  9. +    int      only_one_symbol = 0;
  10. +    int      symbol;
  11.  
  12.      /* Do prediction / make planes */
  13.      switch (c->frame_pred) {
  14. @@ -509,6 +511,38 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
  15.      /* Count the occurences of values */
  16.      count_usage(dst, width, height, counts);
  17.  
  18. +    /* Check for a special case where only one symbol was used */
  19. +    for (symbol = 0; symbol < 256; symbol++) {
  20. +        /* If non-zero count is found, see if it matches width * height */
  21. +        if (counts[symbol]) {
  22. +            only_one_symbol = (counts[symbol] == width * height);
  23. +            break;
  24. +        }
  25. +    }
  26. +
  27. +    /* Special case if only one symbol was used */
  28. +    if (only_one_symbol) {
  29. +        av_log(c->avctx, AV_LOG_WARNING, "Special single symbol case used.\n");
  30. +
  31. +        /* Write a zero for the single symbol used in the plane, else 0xFF */
  32. +        for (i = 0; i < 256; i++) {
  33. +            if (i == symbol)
  34. +                (*pkt_dst)[i] = 0;
  35. +            else
  36. +                (*pkt_dst)[i] = 0xFF;
  37. +        }
  38. +        *pkt_dst += 256;
  39. +
  40. +        /* Write zeroes for lengths */
  41. +        for (i = 0; i < c->slices; i++) {
  42. +            AV_WL32(*pkt_dst + (4 * i), 0);
  43. +        }
  44. +        *pkt_dst += 4 * c->slices;
  45. +
  46. +        /* And that's all for that plane folks */
  47. +        return 0;
  48. +    }
  49. +
  50.      /* Calculate huffman lengths */
  51.      calculate_code_lengths(lengths, counts);
Add Comment
Please, Sign In to add comment