diff x265_glue.c @ 34:5d51fff843eb default tip

A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 08 Mar 2020 19:18:48 +0200
parents 33594243ce31
children
line wrap: on
line diff
--- a/x265_glue.c	Sun Mar 08 19:14:25 2020 +0200
+++ b/x265_glue.c	Sun Mar 08 19:18:48 2020 +0200
@@ -148,17 +148,13 @@
 
 static int x265_encode(HEVCEncoderContext *s, Image *img)
 {
-    int c_count, i, ret;
-    x265_picture *pic;
+    int ret;
     uint32_t nal_count;
     x265_nal *p_nal;
-    pic = s->pic;
+    x265_picture *pic = s->pic;
+    int c_count = (img->format == BPG_FORMAT_GRAY) ? 1 : 3;
 
-    if (img->format == BPG_FORMAT_GRAY)
-        c_count = 1;
-    else
-        c_count = 3;
-    for(i = 0; i < c_count; i++) {
+    for (int i = 0; i < c_count; i++) {
         pic->planes[i] = img->data[i];
         pic->stride[i] = img->linesize[i];
     }
@@ -166,7 +162,7 @@
 
     ret = s->api->encoder_encode(s->enc, &p_nal, &nal_count, pic, NULL);
     if (ret > 0) {
-        for(i = 0; i < nal_count; i++) {
+        for(uint32_t i = 0; i < nal_count; i++) {
             add_nal(s, p_nal[i].payload, p_nal[i].sizeBytes);
         }
     }
@@ -175,7 +171,7 @@
 
 static int x265_close(HEVCEncoderContext *s, uint8_t **pbuf)
 {
-    int buf_len, ret, i;
+    int buf_len, ret;
     uint32_t nal_count;
     x265_nal *p_nal;
 
@@ -184,7 +180,7 @@
         ret = s->api->encoder_encode(s->enc, &p_nal, &nal_count, NULL, NULL);
         if (ret <= 0)
             break;
-        for(i = 0; i < nal_count; i++) {
+        for (uint32_t i = 0; i < nal_count; i++) {
             add_nal(s, p_nal[i].payload, p_nal[i].sizeBytes);
         }
     }