changeset 33:33594243ce31

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 08 Mar 2020 19:14:25 +0200
parents 38ae4a231581
children 5d51fff843eb
files bpgdec.c bpgenc.c bpgenc.h libbpg.c libbpg.h tmalloc.c x265_glue.c
diffstat 7 files changed, 109 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/bpgdec.c	Tue May 16 17:25:59 2017 +0300
+++ b/bpgdec.c	Sun Mar 08 19:14:25 2020 +0200
@@ -167,6 +167,7 @@
 }
 #endif /* USE_PNG */
 
+
 static void bpg_show_info(const char *filename, int show_extensions)
 {
     uint8_t *buf;
--- a/bpgenc.c	Tue May 16 17:25:59 2017 +0300
+++ b/bpgenc.c	Sun Mar 08 19:14:25 2020 +0200
@@ -38,6 +38,8 @@
 
 #include "bpgenc.h"
 
+
+
 typedef uint16_t PIXEL;
 
 static void put_ue(uint8_t **pp, uint32_t v);
@@ -709,10 +711,13 @@
         c_count = 1;
     else
         c_count = 3;
+
     if (has_alpha)
         c_count++;
+
     for(i = 0; i < c_count; i++) {
         get_plane_res(img, &w1, &h1, i);
+
         /* multiple of 16 pixels to add borders */
         w1 = (w1 + (W_PAD - 1)) & ~(W_PAD - 1);
         h1 = (h1 + (W_PAD - 1)) & ~(W_PAD - 1);
@@ -2004,11 +2009,11 @@
     uint8_t *p = *pp;
     int i, j;
 
-    for(i = 1; i < 5; i++) {
+    for (i = 1; i < 5; i++) {
         if (v < (1U << (7 * i)))
             break;
     }
-    for(j = i - 1; j >= 1; j--)
+    for (j = i - 1; j >= 1; j--)
         *p++ = ((v >> (7 * j)) & 0x7f) | 0x80;
     *p++ = v & 0x7f;
     *pp = p;
--- a/bpgenc.h	Tue May 16 17:25:59 2017 +0300
+++ b/bpgenc.h	Sun Mar 08 19:14:25 2020 +0200
@@ -57,7 +57,7 @@
     int verbose;
 } HEVCEncodeParams;
 
-typedef struct HEVCEncoderContext HEVCEncoderContext; 
+typedef struct HEVCEncoderContext HEVCEncoderContext;
 
 typedef struct {
     HEVCEncoderContext *(*open)(const HEVCEncodeParams *params);
@@ -68,7 +68,7 @@
 extern HEVCEncoder jctvc_encoder;
 extern HEVCEncoder x265_hevc_encoder;
 
-int x265_encode_picture(uint8_t **pbuf, Image *img, 
+int x265_encode_picture(uint8_t **pbuf, Image *img,
                         const HEVCEncodeParams *params);
 void save_yuv1(Image *img, FILE *f);
 void save_yuv(Image *img, const char *filename);
--- a/libbpg.c	Tue May 16 17:25:59 2017 +0300
+++ b/libbpg.c	Sun Mar 08 19:14:25 2020 +0200
@@ -1,6 +1,6 @@
 /*
  * libbpg
- * 
+ *
  * Copyright (c) 2014 Fabrice Bellard
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -32,9 +32,9 @@
 
 /* The following global defines are used:
    - USE_VAR_BIT_DEPTH : support of bit depth > 8 bits
-   - USE_PRED : support of animations 
+   - USE_PRED : support of animations
 */
-   
+
 #ifndef EMSCRIPTEN
 #define USE_RGB48 /* support all pixel formats */
 //#define DEBUG
@@ -49,7 +49,7 @@
 
 #define BPG_HEADER_MAGIC 0x425047fb
 
-#define ITAPS2 4 
+#define ITAPS2 4
 #define ITAPS (2 * ITAPS2) /* number of taps of the interpolation filter */
 
 #ifdef USE_VAR_BIT_DEPTH
@@ -71,7 +71,7 @@
     int limited_range;
 } ColorConvertState;
 
-typedef void ColorConvertFunc(ColorConvertState *s, 
+typedef void ColorConvertFunc(ColorConvertState *s,
                               uint8_t *dst, const PIXEL *y_ptr,
                               const PIXEL *cb_ptr, const PIXEL *cr_ptr,
                               int n, int incr);
@@ -152,7 +152,7 @@
     uint32_t v;
     int a;
 
-    if (len <= 0) 
+    if (len <= 0)
         return -1;
     p = buf;
     a = *p++;
@@ -208,7 +208,7 @@
         return -1;
     input_data += ret;
     input_data_len -= ret;
-    
+
     if (len > input_data_len)
         return -1;
 
@@ -230,7 +230,7 @@
     assert(idx == msps_len);
     input_data += len;
     input_data_len -= len;
-    
+
     buf_len = 4 + 2 + msps_len * 2 + 4 + (input_data_len - len);
     buf = av_malloc(buf_len);
 
@@ -239,7 +239,7 @@
     buf[idx++] = 0x00;
     buf[idx++] = 0x00;
     buf[idx++] = 0x00;
-    buf[idx++] = 0x01; 
+    buf[idx++] = 0x01;
     buf[idx++] = (48 << 1); /* application specific NAL unit type */
     buf[idx++] = 1;
 
@@ -259,7 +259,7 @@
     if (idx == 0 || buf[idx - 1] == 0x00)
         buf[idx++] = 0x80;
     av_free(msps_buf);
-    
+
     *pbuf_len = idx;
     *pbuf = buf;
     return input_data_len1 - input_data_len;
@@ -325,7 +325,7 @@
     if (new_size < size)
         new_size = size;
     new_buf = av_realloc(s->buf, new_size);
-    if (!new_buf) 
+    if (!new_buf)
         return -1;
     s->buf = new_buf;
     s->size = new_size;
@@ -344,7 +344,7 @@
 extern AVCodec ff_hevc_decoder;
 
 static int hevc_decode_init1(DynBuf *pbuf, AVFrame **pframe,
-                             AVCodecContext **pc, 
+                             AVCodecContext **pc,
                              const uint8_t *buf, int buf_len,
                              int width, int height, int chroma_format_idc,
                              int bit_depth)
@@ -363,18 +363,18 @@
     av_free(nal_buf);
     if (ret1 < 0)
         return -1;
-    
+
     codec = &ff_hevc_decoder;
 
     c = avcodec_alloc_context3(codec);
-    if (!c) 
+    if (!c)
         return -1;
     frame = av_frame_alloc();
-    if (!frame) 
+    if (!frame)
         return -1;
     /* for testing: use the MD5 or CRC in SEI to check the decoded bit
        stream. */
-    c->err_recognition |= AV_EF_CRCCHECK; 
+    c->err_recognition |= AV_EF_CRCCHECK;
     /* open it */
     if (avcodec_open2(c, codec, NULL) < 0) {
         av_frame_free(&frame);
@@ -430,7 +430,7 @@
         nuh_layer_id = ((buf[start] & 1) << 5) | (buf[start + 1] >> 3);
         nut = (buf[start] >> 1) & 0x3f;
 #if 0
-        printf("nal: type=%d layer_id=%d fs=%d %d\n", 
+        printf("nal: type=%d layer_id=%d fs=%d %d\n",
                nut, nuh_layer_id, frame_start_found[0], frame_start_found[1]);
 #endif
         /* Note: we assume the alpha and color data are correctly
@@ -438,7 +438,7 @@
         if ((nut >= 32 && nut <= 35) || nut == 39 || nut >= 41) {
             if (frame_start_found[0] && frame_start_found[has_alpha])
                 break;
-        } else if ((nut <= 9 || (nut >= 16 && nut <= 21)) &&  
+        } else if ((nut <= 9 || (nut >= 16 && nut <= 21)) &&
                    start + 2 < buf_len && (buf[start + 2] & 0x80)) {
             /* first slice segment */
             if (frame_start_found[0] && frame_start_found[has_alpha])
@@ -448,7 +448,7 @@
             else
                 frame_start_found[0] = 1;
         }
-        
+
         nal_len = find_nal_end(buf, buf_len, !first_nal);
         if (nal_len < 0)
             goto fail;
@@ -471,7 +471,7 @@
         buf_len -= nal_len;
         first_nal = 0;
     }
-    
+
     if (s->alpha_dec_ctx) {
         if (dyn_buf_resize(abuf, abuf->len + FF_INPUT_BUFFER_PADDING_SIZE) < 0)
             goto fail;
@@ -515,15 +515,15 @@
         buf += ret;
         buf_len -= ret;
     }
-    
+
     ret = hevc_decode_init1(cbuf, &s->frame, &s->dec_ctx,
-                            buf, buf_len, width, height, chroma_format_idc, 
+                            buf, buf_len, width, height, chroma_format_idc,
                             bit_depth);
     if (ret < 0)
         goto fail;
     buf += ret;
     buf_len -= ret;
-    
+
     ret = hevc_decode_frame_internal(s, abuf, cbuf, buf, buf_len, 1);
     av_free(abuf->buf);
     av_free(cbuf->buf);
@@ -569,7 +569,7 @@
 uint8_t *bpg_decoder_get_data(BPGDecoderContext *img, int *pline_size, int plane)
 {
     int c_count;
-    if (img->format == BPG_FORMAT_GRAY) 
+    if (img->format == BPG_FORMAT_GRAY)
         c_count = 1;
     else
         c_count = 3;
@@ -647,9 +647,9 @@
     pixel_max = (1 << bit_depth) - 1;
     while (n >= 2) {
         dst[0] = src[0];
-        dst[1] = clamp_pix(((src[-3] + src[4]) * IP0C3 + 
-                            (src[-2] + src[3]) * IP0C2 + 
-                            (src[-1] + src[2]) * IP0C1 + 
+        dst[1] = clamp_pix(((src[-3] + src[4]) * IP0C3 +
+                            (src[-2] + src[3]) * IP0C2 +
+                            (src[-1] + src[2]) * IP0C1 +
                             (src[0] + src[1]) * IP0C0 + 32) >> 6, pixel_max);
         dst += 2;
         src++;
@@ -672,9 +672,9 @@
 
     while (n >= 2) {
         dst[0] = clamp_pix((src[0] + offset0) >> shift0, pixel_max);
-        dst[1] = clamp_pix(((src[-3] + src[4]) * IP0C3 + 
-                            (src[-2] + src[3]) * IP0C2 + 
-                            (src[-1] + src[2]) * IP0C1 + 
+        dst[1] = clamp_pix(((src[-3] + src[4]) * IP0C3 +
+                            (src[-2] + src[3]) * IP0C2 +
+                            (src[-1] + src[2]) * IP0C1 +
                             (src[0] + src[1]) * IP0C0 + offset1) >> shift1,
                            pixel_max);
         dst += 2;
@@ -709,11 +709,11 @@
         a4 = a5;
         a5 = a6;
         a6 = src[3];
-        dst[0] = clamp_pix((a0 * IP1C6 + a1 * IP1C5 + a2 * IP1C4 + a3 * IP1C3 + 
-                            a4 * IP1C2 + a5 * IP1C1 + a6 * IP1C0 + 32) >> 6, 
+        dst[0] = clamp_pix((a0 * IP1C6 + a1 * IP1C5 + a2 * IP1C4 + a3 * IP1C3 +
+                            a4 * IP1C2 + a5 * IP1C1 + a6 * IP1C0 + 32) >> 6,
                            pixel_max);
         dst[1] = clamp_pix((a0 * IP1C0 + a1 * IP1C1 + a2 * IP1C2 + a3 * IP1C3 +
-                            a4 * IP1C4 + a5 * IP1C5 + a6 * IP1C6 + 32) >> 6, 
+                            a4 * IP1C4 + a5 * IP1C5 + a6 * IP1C6 + 32) >> 6,
                            pixel_max);
         dst += 2;
         src++;
@@ -727,13 +727,13 @@
         a4 = a5;
         a5 = a6;
         a6 = src[3];
-        dst[0] = clamp_pix((a0 * IP1C6 + a1 * IP1C5 + a2 * IP1C4 + a3 * IP1C3 + 
-                            a4 * IP1C2 + a5 * IP1C1 + a6 * IP1C0 + 32) >> 6, 
+        dst[0] = clamp_pix((a0 * IP1C6 + a1 * IP1C5 + a2 * IP1C4 + a3 * IP1C3 +
+                            a4 * IP1C2 + a5 * IP1C1 + a6 * IP1C0 + 32) >> 6,
                            pixel_max);
     }
 }
 
-static void interp2p1_simple16(PIXEL *dst, const int16_t *src, int n, 
+static void interp2p1_simple16(PIXEL *dst, const int16_t *src, int n,
                                int bit_depth)
 {
     int shift, offset, pixel_max, a0, a1, a2, a3, a4, a5, a6;
@@ -776,7 +776,7 @@
         a5 = a6;
         a6 = src[3];
         dst[0] = clamp_pix((a0 * IP1C6 + a1 * IP1C5 + a2 * IP1C4 + a3 * IP1C3 +
-                            a4 * IP1C2 + a5 * IP1C1 + a6 * IP1C0 + offset) >> shift, 
+                            a4 * IP1C2 + a5 * IP1C1 + a6 * IP1C0 + offset) >> shift,
                            pixel_max);
     }
 }
@@ -829,18 +829,18 @@
     n2 = (n + 1) / 2;
     if (frac_pos == 0) {
         for(i = 0; i < n2; i++) {
-            tmp_buf[ITAPS2 - 1 + i] = 
-                (src0[i] * IP1C6 + src1[i] * IP1C5 + 
-                 src2[i] * IP1C4 + src3[i] * IP1C3 + 
-                 src4[i] * IP1C2 + src5[i] * IP1C1 + 
+            tmp_buf[ITAPS2 - 1 + i] =
+                (src0[i] * IP1C6 + src1[i] * IP1C5 +
+                 src2[i] * IP1C4 + src3[i] * IP1C3 +
+                 src4[i] * IP1C2 + src5[i] * IP1C1 +
                  src6[i] * IP1C0 + rnd) >> shift;
         }
     } else {
         for(i = 0; i < n2; i++) {
-            tmp_buf[ITAPS2 - 1 + i] = 
-                (src0[i] * IP1C0 + src1[i] * IP1C1 + 
-                 src2[i] * IP1C2 + src3[i] * IP1C3 + 
-                 src4[i] * IP1C4 + src5[i] * IP1C5 + 
+            tmp_buf[ITAPS2 - 1 + i] =
+                (src0[i] * IP1C0 + src1[i] * IP1C1 +
+                 src2[i] * IP1C2 + src3[i] * IP1C3 +
+                 src4[i] * IP1C4 + src5[i] * IP1C5 +
                  src6[i] * IP1C6 + rnd) >> shift;
         }
     }
@@ -885,7 +885,7 @@
     }
 }
 
-static void ycgco_to_rgb24(ColorConvertState *s, 
+static void ycgco_to_rgb24(ColorConvertState *s,
                            uint8_t *dst, const PIXEL *y_ptr,
                            const PIXEL *cb_ptr, const PIXEL *cr_ptr,
                            int n, int incr)
@@ -910,7 +910,7 @@
 }
 
 /* c = c * alpha */
-static void alpha_combine8(ColorConvertState *s, 
+static void alpha_combine8(ColorConvertState *s,
                            uint8_t *dst, const PIXEL *a_ptr, int n, int incr)
 {
     uint8_t *q = dst;
@@ -979,7 +979,7 @@
     }
 }
 
-static void gray_to_rgb24(ColorConvertState *s, 
+static void gray_to_rgb24(ColorConvertState *s,
                           uint8_t *dst, const PIXEL *y_ptr,
                           const PIXEL *cb_ptr, const PIXEL *cr_ptr,
                           int n, int incr)
@@ -1047,7 +1047,7 @@
     }
 }
 
-static void gray_to_gray8(ColorConvertState *s, 
+static void gray_to_gray8(ColorConvertState *s,
                           uint8_t *dst, const PIXEL *y_ptr,
                           int n, int incr)
 {
@@ -1121,7 +1121,7 @@
     }
 }
 
-static void ycgco_to_rgb48(ColorConvertState *s, 
+static void ycgco_to_rgb48(ColorConvertState *s,
                            uint8_t *dst, const PIXEL *y_ptr,
                            const PIXEL *cb_ptr, const PIXEL *cr_ptr,
                            int n, int incr)
@@ -1145,7 +1145,7 @@
     }
 }
 
-static void gray_to_rgb48(ColorConvertState *s, 
+static void gray_to_rgb48(ColorConvertState *s,
                           uint8_t *dst, const PIXEL *y_ptr,
                           const PIXEL *cb_ptr, const PIXEL *cr_ptr,
                           int n, int incr)
@@ -1167,7 +1167,7 @@
     }
 }
 
-static void gray_to_gray16(ColorConvertState *s, 
+static void gray_to_gray16(ColorConvertState *s,
                            uint16_t *dst, const PIXEL *y_ptr,
                            int n, int incr)
 {
@@ -1184,7 +1184,7 @@
     }
 }
 
-static void luma_to_gray16(ColorConvertState *s, 
+static void luma_to_gray16(ColorConvertState *s,
                            uint16_t *dst, const PIXEL *y_ptr,
                            int n, int incr)
 {
@@ -1201,7 +1201,7 @@
     }
 }
 
-static void rgb_to_rgb48(ColorConvertState *s, 
+static void rgb_to_rgb48(ColorConvertState *s,
                          uint8_t *dst, const PIXEL *y_ptr,
                          const PIXEL *cb_ptr, const PIXEL *cr_ptr,
                          int n, int incr)
@@ -1221,7 +1221,7 @@
 }
 
 /* c = c * alpha */
-static void alpha_combine16(ColorConvertState *s, 
+static void alpha_combine16(ColorConvertState *s,
                             uint16_t *dst, const PIXEL *a_ptr, int n, int incr)
 {
     uint16_t *q = dst;
@@ -1299,7 +1299,7 @@
 };
 #endif
 
-static void convert_init(ColorConvertState *s, 
+static void convert_init(ColorConvertState *s,
                          int in_bit_depth, int out_bit_depth,
                          BPGColorSpaceEnum color_space,
                          int limited_range)
@@ -1312,9 +1312,9 @@
     out_pixel_max = (1 << out_bit_depth) - 1;
     mult = (double)out_pixel_max * (1 << c_shift) / (double)in_pixel_max;
     if (limited_range) {
-        mult_y = (double)out_pixel_max * (1 << c_shift) / 
+        mult_y = (double)out_pixel_max * (1 << c_shift) /
             (double)(219 << (in_bit_depth - 8));
-        mult_c = (double)out_pixel_max * (1 << c_shift) / 
+        mult_c = (double)out_pixel_max * (1 << c_shift) /
             (double)(224 << (in_bit_depth - 8));
     } else {
         mult_y = mult;
@@ -1326,7 +1326,7 @@
         k_b = 0.114;
         goto convert_ycc;
     case BPG_CS_YCbCr_BT709:
-        k_r = 0.2126; 
+        k_r = 0.2126;
         k_b = 0.0722;
         goto convert_ycc;
     case BPG_CS_YCbCr_BT2020:
@@ -1375,7 +1375,7 @@
                    out_fmt == BPG_OUTPUT_FORMAT_CMYK64);
     s->is_cmyk = (out_fmt == BPG_OUTPUT_FORMAT_CMYK32 ||
                   out_fmt == BPG_OUTPUT_FORMAT_CMYK64);
-    
+
     if (s->format == BPG_FORMAT_420 || s->format == BPG_FORMAT_422) {
         s->w2 = (s->w + 1) / 2;
         s->h2 = (s->h + 1) / 2;
@@ -1398,7 +1398,7 @@
 #ifdef USE_RGB48
         if (s->is_16bpp) {
             s->cvt_func = gray_to_rgb48;
-        } else 
+        } else
 #endif
         {
             s->cvt_func = gray_to_rgb24;
@@ -1435,7 +1435,7 @@
 
     if (!s->frame)
         return -1;
-    
+
     if (!s->output_inited) {
         /* first frame is already decoded */
         ret = bpg_decoder_output_init(s, out_fmt);
@@ -1451,13 +1451,13 @@
             if (s->input_buf_pos >= s->input_buf_len) {
                 return -1;
             } else {
-                ret = hevc_decode_frame(s, s->input_buf + s->input_buf_pos, 
+                ret = hevc_decode_frame(s, s->input_buf + s->input_buf_pos,
                                         s->input_buf_len - s->input_buf_pos);
                 if (ret < 0)
                     return -1;
                 s->input_buf_pos += ret;
             }
-        } else 
+        } else
 #endif
         {
             return -1;
@@ -1485,7 +1485,7 @@
     if (s->frame && s->has_animation) {
         *pnum = s->frame_delay_num * (s->frame->pts);
         *pden = s->frame_delay_den;
-    } else 
+    } else
 #endif
     {
         *pnum = 0;
@@ -1500,10 +1500,10 @@
     PIXEL *y_ptr, *cb_ptr, *cr_ptr, *a_ptr;
 
     y = s->y;
-    if ((unsigned)y >= s->h) 
+    if ((unsigned)y >= s->h)
         return -1;
     w = s->w;
-    
+
     y_ptr = (PIXEL *)(s->y_buf + y * s->y_linesize);
     incr = 3 + (s->is_rgba || s->is_cmyk);
     switch(s->format) {
@@ -1551,7 +1551,7 @@
     case BPG_FORMAT_422:
         cb_ptr = (PIXEL *)(s->cb_buf + y * s->cb_linesize);
         cr_ptr = (PIXEL *)(s->cr_buf + y * s->cr_linesize);
-        interp2_h(s->cb_buf2, cb_ptr, w, s->bit_depth, s->c_h_phase, 
+        interp2_h(s->cb_buf2, cb_ptr, w, s->bit_depth, s->c_h_phase,
                   (PIXEL *)s->c_buf4);
         interp2_h(s->cr_buf2, cr_ptr, w, s->bit_depth, s->c_h_phase,
                   (PIXEL *)s->c_buf4);
@@ -1603,7 +1603,7 @@
         if (s->is_16bpp) {
             if (s->has_alpha) {
                 a_ptr = (PIXEL *)(s->a_buf + y * s->a_linesize);
-                gray_to_gray16(&s->cvt, 
+                gray_to_gray16(&s->cvt,
                                (uint16_t *)rgb_line + 3, a_ptr, w, 4);
                 if (s->premultiplied_alpha)
                     alpha_divide16((uint16_t *)rgb_line, w);
@@ -1692,7 +1692,7 @@
     h->has_alpha = 0;
     h->has_w_plane = 0;
     h->premultiplied_alpha = 0;
-    
+
     if (alpha1_flag) {
         h->has_alpha = 1;
         h->premultiplied_alpha = alpha2_flag;
@@ -1701,7 +1701,7 @@
         h->has_w_plane = 1;
     }
 
-    if (h->color_space >= BPG_CS_COUNT || 
+    if (h->color_space >= BPG_CS_COUNT ||
         (h->format == BPG_FORMAT_GRAY && h->color_space != 0) ||
         (h->has_w_plane && h->format == BPG_FORMAT_GRAY))
         return -1;
@@ -1722,7 +1722,7 @@
     if (ret < 0)
         return -1;
     idx += ret;
-           
+
     extension_data_len = 0;
     if (has_extension) {
         ret = get_ue(&extension_data_len, buf + idx, buf_len - idx);
@@ -1745,15 +1745,15 @@
             plast_md = &h->first_md;
             while (idx < ext_end) {
                 ret = get_ue32(&tag, buf + idx, ext_end - idx);
-                if (ret < 0) 
+                if (ret < 0)
                     goto fail;
                 idx += ret;
 
                 ret = get_ue(&buf_len, buf + idx, ext_end - idx);
-                if (ret < 0) 
+                if (ret < 0)
                     goto fail;
                 idx += ret;
-                
+
                 if (idx + buf_len > ext_end) {
                 fail:
                     bpg_decoder_free_extension_data(h->first_md);
@@ -1765,15 +1765,15 @@
 
                     idx1 = idx;
                     ret = get_ue(&loop_count, buf + idx1, ext_end - idx1);
-                    if (ret < 0) 
+                    if (ret < 0)
                         goto fail;
                     idx1 += ret;
                     ret = get_ue(&frame_delay_num, buf + idx1, ext_end - idx1);
-                    if (ret < 0) 
+                    if (ret < 0)
                         goto fail;
                     idx1 += ret;
                     ret = get_ue(&frame_delay_den, buf + idx1, ext_end - idx1);
-                    if (ret < 0) 
+                    if (ret < 0)
                         goto fail;
                     idx1 += ret;
                     if (frame_delay_num == 0 || frame_delay_den == 0 ||
@@ -1792,7 +1792,7 @@
                     md->next = NULL;
                     *plast_md = md;
                     plast_md = &md->next;
-                    
+
                     md->buf = av_malloc(md->buf_len);
                     memcpy(md->buf, buf + idx, md->buf_len);
                 }
@@ -1811,7 +1811,7 @@
 
     if (h->hevc_data_len == 0)
         h->hevc_data_len = buf_len - idx;
-    
+
     return idx;
 }
 
@@ -1829,7 +1829,7 @@
     has_alpha = h->has_alpha;
     color_space = h->color_space;
     bit_depth = h->bit_depth;
-    
+
     img->w = width;
     img->h = height;
     img->format = h->format;
@@ -1869,7 +1869,7 @@
 #ifdef USE_PRED
     /* XXX: add an option to avoid decoding animations ? */
     img->decode_animation = 1;
-    if (img->has_animation && img->decode_animation) { 
+    if (img->has_animation && img->decode_animation) {
         int len;
         /* keep trailing bitstream to decode the next frames */
         len = buf_len - idx;
@@ -1879,7 +1879,7 @@
         memcpy(img->input_buf, buf + idx, len);
         img->input_buf_len = len;
         img->input_buf_pos = 0;
-    } else 
+    } else
 #endif
     {
         hevc_decode_end(img);
@@ -1912,7 +1912,7 @@
 {
 #ifndef EMSCRIPTEN
     BPGExtensionData *md, *md_next;
-    
+
     for(md = first_md; md != NULL; md = md_next) {
         md_next = md->next;
         av_free(md->buf);
@@ -1932,7 +1932,7 @@
     return s->first_md;
 }
 
-int bpg_decoder_get_info_from_buf(BPGImageInfo *p, 
+int bpg_decoder_get_info_from_buf(BPGImageInfo *p,
                                   BPGExtensionData **pfirst_md,
                                   const uint8_t *buf, int buf_len)
 {
@@ -1940,7 +1940,7 @@
     int parse_extension;
 
     parse_extension = (pfirst_md != NULL);
-    if (bpg_decode_header(h, buf, buf_len, 
+    if (bpg_decode_header(h, buf, buf_len,
                           !parse_extension, parse_extension) < 0)
         return -1;
     p->width = h->width;
--- a/libbpg.h	Tue May 16 17:25:59 2017 +0300
+++ b/libbpg.h	Sun Mar 08 19:14:25 2020 +0200
@@ -1,6 +1,6 @@
 /*
  * BPG decoder
- * 
+ *
  * Copyright (c) 2014 Fabrice Bellard
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -129,7 +129,7 @@
    BPGImageInfo.loop_count is only set if extension data are parsed.
 
    Return 0 if OK, < 0 if unrecognized data. */
-int bpg_decoder_get_info_from_buf(BPGImageInfo *p, 
+int bpg_decoder_get_info_from_buf(BPGImageInfo *p,
                                   BPGExtensionData **pfirst_md,
                                   const uint8_t *buf, int buf_len);
 /* Free the extension data returned by bpg_decoder_get_info_from_buf() */
--- a/tmalloc.c	Tue May 16 17:25:59 2017 +0300
+++ b/tmalloc.c	Sun Mar 08 19:14:25 2020 +0200
@@ -1,6 +1,6 @@
 /*
  * Tiny malloc
- * 
+ *
  * Copyright (c) 2014 Fabrice Bellard
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -129,7 +129,7 @@
         p = sbrk(MALLOC_BLOCK_SIZE * 2);
         if (p == (void *)-1)
             return NULL;
-        
+
         mem_top = sbrk(0);
         free_list.prev = free_list.next = &free_list;
         block_list.prev = block_list.next = &block_list;
@@ -225,7 +225,7 @@
         if (!ptr1)
             return NULL;
         /* Note: never the last block so it is valid */
-        size1 = (uint8_t *)list_entry(p->link.next, MemBlock, link) - 
+        size1 = (uint8_t *)list_entry(p->link.next, MemBlock, link) -
             p->u.data - 1;
         if (size < size1)
             size1 = size;
@@ -266,11 +266,11 @@
 {
     MemBlock *p;
     struct list_head *el;
-    
+
     printf("blocks:\n");
     for(el = block_list.next; el != &block_list; el = el->next) {
         p = list_entry(el, MemBlock, link);
-        printf("block: %p next=%p free=%d size=%u\n", p, p->link.next, 
+        printf("block: %p next=%p free=%d size=%u\n", p, p->link.next,
                get_block_state(p) == STATE_FREE,
                (unsigned int)get_block_size(p));
     }
--- a/x265_glue.c	Tue May 16 17:25:59 2017 +0300
+++ b/x265_glue.c	Sun Mar 08 19:14:25 2020 +0200
@@ -1,5 +1,5 @@
 /*
- * x265 encoder front-end  
+ * x265 encoder front-end
  *
  * Copyright (c) 2014 Fabrice Bellard
  *
@@ -45,7 +45,7 @@
     x265_param *p;
     int preset_index;
     const char *preset;
-    
+
     s = malloc(sizeof(HEVCEncoderContext));
     memset(s, 0, sizeof(*s));
 
@@ -61,7 +61,7 @@
         return NULL;
     }
 #endif
-    
+
     p = s->api->param_alloc();
 
     preset_index = params->compress_level; /* 9 is placebo */
@@ -69,7 +69,7 @@
     preset = x265_preset_names[preset_index];
     if (params->verbose)
         printf("Using x265 preset: %s\n", preset);
-    
+
     s->api->param_default_preset(p, preset, "ssim");
 
     p->bRepeatHeaders = 1;
@@ -109,7 +109,7 @@
         p->logLevel = X265_LOG_INFO;
     else
         p->logLevel = X265_LOG_NONE;
-        
+
     /* dummy frame rate */
     p->fpsNum = 25;
     p->fpsDenom = 1;
@@ -152,7 +152,6 @@
     x265_picture *pic;
     uint32_t nal_count;
     x265_nal *p_nal;
-    
     pic = s->pic;
 
     if (img->format == BPG_FORMAT_GRAY)
@@ -179,7 +178,7 @@
     int buf_len, ret, i;
     uint32_t nal_count;
     x265_nal *p_nal;
-    
+
     /* get last compressed pictures */
     for(;;) {
         ret = s->api->encoder_encode(s->enc, &p_nal, &nal_count, NULL, NULL);