mike-jumper commented on a change in pull request #159: GUACAMOLE-465: 
beginning to support new codecs and containers
URL: https://github.com/apache/guacamole-server/pull/159#discussion_r371048306
 
 

 ##########
 File path: src/guacenc/ffmpeg-compat.c
 ##########
 @@ -165,3 +194,56 @@ int guacenc_avcodec_encode_video(guacenc_video* video, 
AVFrame* frame) {
 #endif
 }
 
+AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, AVCodec* codec, 
+        int bitrate, int width, int height, int gop_size, int qmax, int qmin,
+        int pix_fmt, AVRational time_base) {
+
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 33, 100)
+    stream->codec->bit_rate = bitrate;
+    stream->codec->width = width;
+    stream->codec->height = height;
+    stream->codec->gop_size = gop_size;
+    stream->codec->qmax = qmax;
+    stream->codec->qmin = qmin;
+    stream->codec->pix_fmt = pix_fmt;
+    stream->codec->time_base = time_base;
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(55, 44, 100)
+    stream->codec->time_base = time_base;
+#else
+    stream->time_base = time_base;
+#endif
+    return stream->codec;
+#else
+    AVCodecContext* context = avcodec_alloc_context3(codec);
+    if (context) {
+        context->bit_rate = bitrate;
+        context->width = width;
+        context->height = height;
+        context->gop_size = gop_size;
+        context->qmax = qmax;
+        context->qmin = qmin;
+        context->pix_fmt = pix_fmt;
+        context->time_base = time_base;
+        stream->time_base = time_base;
+    }
+    return context;
+#endif
+
+}
+
+int guacenc_open_avcodec(AVCodecContext *avcodec_context,
+        AVCodec *codec, AVDictionary **options,
+        AVStream* stream) {
+    int ret = 0;
+    ret = avcodec_open2(avcodec_context, codec, options);
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 33, 100)
+    int codecpar_ret = 0;
+    /* copy stream parameters to the muxer */
+    codecpar_ret = avcodec_parameters_from_context(stream->codecpar,
+            avcodec_context);
 
 Review comment:
   Same here - as `codecpar_ret` is initialized, only to have that value 
immediately overwritten by the return value of 
`avcodec_parameters_from_context()`, it would be better to just initialized the 
variable with that return value directly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to