Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
- index ef6a614..6896087 100644
- --- a/libavcodec/utvideoenc.c
- +++ b/libavcodec/utvideoenc.c
- @@ -473,6 +473,8 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
- uint32_t offset = 0, slice_len = 0;
- int i, sstart, send = 0;
- + int only_one_symbol = 0;
- + int symbol;
- /* Do prediction / make planes */
- switch (c->frame_pred) {
- @@ -509,6 +511,38 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
- /* Count the occurences of values */
- count_usage(dst, width, height, counts);
- + /* Check for a special case where only one symbol was used */
- + for (symbol = 0; symbol < 256; symbol++) {
- + /* If non-zero count is found, see if it matches width * height */
- + if (counts[symbol]) {
- + only_one_symbol = (counts[symbol] == width * height);
- + break;
- + }
- + }
- +
- + /* Special case if only one symbol was used */
- + if (only_one_symbol) {
- + av_log(c->avctx, AV_LOG_WARNING, "Special single symbol case used.\n");
- +
- + /* Write a zero for the single symbol used in the plane, else 0xFF */
- + for (i = 0; i < 256; i++) {
- + if (i == symbol)
- + (*pkt_dst)[i] = 0;
- + else
- + (*pkt_dst)[i] = 0xFF;
- + }
- + *pkt_dst += 256;
- +
- + /* Write zeroes for lengths */
- + for (i = 0; i < c->slices; i++) {
- + AV_WL32(*pkt_dst + (4 * i), 0);
- + }
- + *pkt_dst += 4 * c->slices;
- +
- + /* And that's all for that plane folks */
- + return 0;
- + }
- +
- /* Calculate huffman lengths */
- calculate_code_lengths(lengths, counts);
Add Comment
Please, Sign In to add comment