[x265] [PATCH] api: change signature of x265_csvlog_encode()

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Thu Jan 4 11:05:42 CET 2018


# HG changeset patch
# User Aarthi Thirumalai <aarthi at multicorewareinc.com>
# Date 1515059166 -19800
#      Thu Jan 04 15:16:06 2018 +0530
# Node ID f29e88d85ca29d23c05d3c7d03f0f506a12bc780
# Parent  5f6f6189a239aad91505ee1ed8b1874450779a2a
api: change signature of x265_csvlog_encode()

replace x265_encoder* with x265_param* and int padx, int pady as function arguments.

diff -r 5f6f6189a239 -r f29e88d85ca2 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Jan 04 13:56:07 2018 +0530
+++ b/source/CMakeLists.txt	Thu Jan 04 15:16:06 2018 +0530
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 150)
+set(X265_BUILD 151)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 5f6f6189a239 -r f29e88d85ca2 source/encoder/api.cpp
--- a/source/encoder/api.cpp	Thu Jan 04 13:56:07 2018 +0530
+++ b/source/encoder/api.cpp	Thu Jan 04 15:16:06 2018 +0530
@@ -312,7 +312,9 @@
         Encoder *encoder = static_cast<Encoder*>(enc);
         x265_stats stats;
         encoder->fetchStats(&stats, sizeof(stats));
-        x265_csvlog_encode(enc, &stats, argc, argv);
+        int padx = encoder->m_sps.conformanceWindow.rightOffset;
+        int pady = encoder->m_sps.conformanceWindow.bottomOffset;
+        x265_csvlog_encode(encoder->m_param, &stats, padx, pady, argc, argv);
     }
 }
 
@@ -868,45 +870,38 @@
     fflush(stderr);
 }
 
-void x265_csvlog_encode(x265_encoder *enc, const x265_stats* stats, int argc, char** argv)
+void x265_csvlog_encode(const x265_param *p, const x265_stats *stats, int padx, int pady, int argc, char** argv)
 {
-    if (enc)
+    if (p && p->csvfpt)
     {
-        Encoder *encoder = static_cast<Encoder*>(enc);
-        int padx = encoder->m_sps.conformanceWindow.rightOffset;
-        int pady = encoder->m_sps.conformanceWindow.bottomOffset;
         const x265_api * api = x265_api_get(0);
 
-        if (!encoder->m_param->csvfpt)
-            return;
-
-        if (encoder->m_param->csvLogLevel)
+        if (p->csvLogLevel)
         {
             // adding summary to a per-frame csv log file, so it needs a summary header
-            fprintf(encoder->m_param->csvfpt, "\nSummary\n");
-            fputs(summaryCSVHeader, encoder->m_param->csvfpt);
+            fprintf(p->csvfpt, "\nSummary\n");
+            fputs(summaryCSVHeader, p->csvfpt);
         }
 
         // CLI arguments or other
         if (argc)
         {
-            fputc('"', encoder->m_param->csvfpt);
+            fputc('"', p->csvfpt);
             for (int i = 1; i < argc; i++)
             {
-                fputc(' ', encoder->m_param->csvfpt);
-                fputs(argv[i], encoder->m_param->csvfpt);
+                fputc(' ', p->csvfpt);
+                fputs(argv[i], p->csvfpt);
             }
-            fputc('"', encoder->m_param->csvfpt);
+            fputc('"', p->csvfpt);
         }
         else
         {
-            const x265_param* paramTemp = encoder->m_param;
-            char *opts = x265_param2string((x265_param*)paramTemp, padx, pady);
+            char *opts = x265_param2string((x265_param*)p, padx, pady);
             if (opts)
             {
-                fputc('"', encoder->m_param->csvfpt);
-                fputs(opts, encoder->m_param->csvfpt);
-                fputc('"', encoder->m_param->csvfpt);
+                fputc('"', p->csvfpt);
+                fputs(opts, p->csvfpt);
+                fputc('"', p->csvfpt);
             }
         }
 
@@ -917,70 +912,71 @@
         timeinfo = localtime(&now);
         char buffer[200];
         strftime(buffer, 128, "%c", timeinfo);
-        fprintf(encoder->m_param->csvfpt, ", %s, ", buffer);
+        fprintf(p->csvfpt, ", %s, ", buffer);
 
         // elapsed time, fps, bitrate
-        fprintf(encoder->m_param->csvfpt, "%.2f, %.2f, %.2f,",
+        fprintf(p->csvfpt, "%.2f, %.2f, %.2f,",
             stats->elapsedEncodeTime, stats->encodedPictureCount / stats->elapsedEncodeTime, stats->bitrate);
 
-        if (encoder->m_param->bEnablePsnr)
-            fprintf(encoder->m_param->csvfpt, " %.3lf, %.3lf, %.3lf, %.3lf,",
+        if (p->bEnablePsnr)
+            fprintf(p->csvfpt, " %.3lf, %.3lf, %.3lf, %.3lf,",
             stats->globalPsnrY / stats->encodedPictureCount, stats->globalPsnrU / stats->encodedPictureCount,
             stats->globalPsnrV / stats->encodedPictureCount, stats->globalPsnr);
         else
-            fprintf(encoder->m_param->csvfpt, " -, -, -, -,");
-        if (encoder->m_param->bEnableSsim)
-            fprintf(encoder->m_param->csvfpt, " %.6f, %6.3f,", stats->globalSsim, x265_ssim2dB(stats->globalSsim));
+            fprintf(p->csvfpt, " -, -, -, -,");
+        if (p->bEnableSsim)
+            fprintf(p->csvfpt, " %.6f, %6.3f,", stats->globalSsim, x265_ssim2dB(stats->globalSsim));
         else
-            fprintf(encoder->m_param->csvfpt, " -, -,");
+            fprintf(p->csvfpt, " -, -,");
 
         if (stats->statsI.numPics)
         {
-            fprintf(encoder->m_param->csvfpt, " %-6u, %2.2lf, %-8.2lf,", stats->statsI.numPics, stats->statsI.avgQp, stats->statsI.bitrate);
-            if (encoder->m_param->bEnablePsnr)
-                fprintf(encoder->m_param->csvfpt, " %.3lf, %.3lf, %.3lf,", stats->statsI.psnrY, stats->statsI.psnrU, stats->statsI.psnrV);
+            fprintf(p->csvfpt, " %-6u, %2.2lf, %-8.2lf,", stats->statsI.numPics, stats->statsI.avgQp, stats->statsI.bitrate);
+            if (p->bEnablePsnr)
+                fprintf(p->csvfpt, " %.3lf, %.3lf, %.3lf,", stats->statsI.psnrY, stats->statsI.psnrU, stats->statsI.psnrV);
             else
-                fprintf(encoder->m_param->csvfpt, " -, -, -,");
-            if (encoder->m_param->bEnableSsim)
-                fprintf(encoder->m_param->csvfpt, " %.3lf,", stats->statsI.ssim);
+                fprintf(p->csvfpt, " -, -, -,");
+            if (p->bEnableSsim)
+                fprintf(p->csvfpt, " %.3lf,", stats->statsI.ssim);
             else
-                fprintf(encoder->m_param->csvfpt, " -,");
+                fprintf(p->csvfpt, " -,");
         }
         else
-            fprintf(encoder->m_param->csvfpt, " -, -, -, -, -, -, -,");
+            fprintf(p->csvfpt, " -, -, -, -, -, -, -,");
 
         if (stats->statsP.numPics)
         {
-            fprintf(encoder->m_param->csvfpt, " %-6u, %2.2lf, %-8.2lf,", stats->statsP.numPics, stats->statsP.avgQp, stats->statsP.bitrate);
-            if (encoder->m_param->bEnablePsnr)
-                fprintf(encoder->m_param->csvfpt, " %.3lf, %.3lf, %.3lf,", stats->statsP.psnrY, stats->statsP.psnrU, stats->statsP.psnrV);
+            fprintf(p->csvfpt, " %-6u, %2.2lf, %-8.2lf,", stats->statsP.numPics, stats->statsP.avgQp, stats->statsP.bitrate);
+            if (p->bEnablePsnr)
+                fprintf(p->csvfpt, " %.3lf, %.3lf, %.3lf,", stats->statsP.psnrY, stats->statsP.psnrU, stats->statsP.psnrV);
             else
-                fprintf(encoder->m_param->csvfpt, " -, -, -,");
-            if (encoder->m_param->bEnableSsim)
-                fprintf(encoder->m_param->csvfpt, " %.3lf,", stats->statsP.ssim);
+                fprintf(p->csvfpt, " -, -, -,");
+            if (p->bEnableSsim)
+                fprintf(p->csvfpt, " %.3lf,", stats->statsP.ssim);
             else
-                fprintf(encoder->m_param->csvfpt, " -,");
+                fprintf(p->csvfpt, " -,");
         }
         else
-            fprintf(encoder->m_param->csvfpt, " -, -, -, -, -, -, -,");
+            fprintf(p->csvfpt, " -, -, -, -, -, -, -,");
 
         if (stats->statsB.numPics)
         {
-            fprintf(encoder->m_param->csvfpt, " %-6u, %2.2lf, %-8.2lf,", stats->statsB.numPics, stats->statsB.avgQp, stats->statsB.bitrate);
-            if (encoder->m_param->bEnablePsnr)
-                fprintf(encoder->m_param->csvfpt, " %.3lf, %.3lf, %.3lf,", stats->statsB.psnrY, stats->statsB.psnrU, stats->statsB.psnrV);
+            fprintf(p->csvfpt, " %-6u, %2.2lf, %-8.2lf,", stats->statsB.numPics, stats->statsB.avgQp, stats->statsB.bitrate);
+            if (p->bEnablePsnr)
+                fprintf(p->csvfpt, " %.3lf, %.3lf, %.3lf,", stats->statsB.psnrY, stats->statsB.psnrU, stats->statsB.psnrV);
             else
-                fprintf(encoder->m_param->csvfpt, " -, -, -,");
-            if (encoder->m_param->bEnableSsim)
-                fprintf(encoder->m_param->csvfpt, " %.3lf,", stats->statsB.ssim);
+                fprintf(p->csvfpt, " -, -, -,");
+            if (p->bEnableSsim)
+                fprintf(p->csvfpt, " %.3lf,", stats->statsB.ssim);
             else
-                fprintf(encoder->m_param->csvfpt, " -,");
+                fprintf(p->csvfpt, " -,");
         }
         else
-            fprintf(encoder->m_param->csvfpt, " -, -, -, -, -, -, -,");
+            fprintf(p->csvfpt, " -, -, -, -, -, -, -,");
 
-        fprintf(encoder->m_param->csvfpt, " %-6u, %-6u, %s\n", stats->maxCLL, stats->maxFALL, api->version_str);
+        fprintf(p->csvfpt, " %-6u, %-6u, %s\n", stats->maxCLL, stats->maxFALL, api->version_str);
     }
+
 }
 
 /* The dithering algorithm is based on Sierra-2-4A error diffusion.
diff -r 5f6f6189a239 -r f29e88d85ca2 source/x265.h
--- a/source/x265.h	Thu Jan 04 13:56:07 2018 +0530
+++ b/source/x265.h	Thu Jan 04 15:16:06 2018 +0530
@@ -1779,9 +1779,10 @@
 void x265_csvlog_frame(const x265_param *, const x265_picture *);
 
 /* Log final encode statistics to the CSV file handle. 'argc' and 'argv' are
- * intended to be command line arguments passed to the encoder. Encode
+ * intended to be command line arguments passed to the encoder. padx and pady are
+ * padding offsets for conformance and can be given from sps settings. Encode
  * statistics should be queried from the encoder just prior to closing it. */
-void x265_csvlog_encode(x265_encoder *encoder, const x265_stats *, int argc, char** argv);
+void x265_csvlog_encode(const x265_param*, const x265_stats *, int padx, int pady, int argc, char** argv);
 
 /* In-place downshift from a bit-depth greater than 8 to a bit-depth of 8, using
  * the residual bits to dither each row. */
@@ -1836,7 +1837,7 @@
     int           (*get_ref_frame_list)(x265_encoder*, x265_picyuv**, x265_picyuv**, int, int, int*, int*);
     FILE*         (*csvlog_open)(const x265_param*);
     void          (*csvlog_frame)(const x265_param*, const x265_picture*);
-    void          (*csvlog_encode)(x265_encoder*, const x265_stats*, int, char**);
+    void          (*csvlog_encode)(const x265_param*, const x265_stats *, int, int, int, char**);
     void          (*dither_image)(x265_picture*, int, int, int16_t*, int);
     int           (*set_analysis_data)(x265_encoder *encoder, x265_analysis_data *analysis_data, int poc, uint32_t cuBytes);
     /* add new pointers to the end, or increment X265_MAJOR_VERSION */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265.patch
Type: text/x-patch
Size: 11076 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20180104/988be76d/attachment-0001.bin>


More information about the x265-devel mailing list