diff mbox series

[FFmpeg-devel,28/39] avcodec/omx: Reindentation

Message ID HE1PR0301MB21547BE08F5BC8DA47CB2D478F299@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 964c826f5507978e76c4b9fe5f5ad976909f273e
Headers show
Series [FFmpeg-devel,01/39] avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1 | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 21, 2021, 9:17 a.m. UTC
Also combine two if blocks that check for the same condition
and don't check had_partial if we already have a complete packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/omx.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 1e48579d4b..ddb3ba4f66 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -863,26 +863,21 @@  static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             avctx->extradata_size += buffer->nFilledLen;
             memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
         } else {
-                int newsize = s->output_buf_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE;
-                if ((ret = av_reallocp(&s->output_buf, newsize)) < 0) {
+            int newsize = s->output_buf_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE;
+            if ((ret = av_reallocp(&s->output_buf, newsize)) < 0) {
+                s->output_buf_size = 0;
+                goto end;
+            }
+            memcpy(s->output_buf + s->output_buf_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
+            s->output_buf_size += buffer->nFilledLen;
+            if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) {
+                if ((ret = av_packet_from_data(pkt, s->output_buf, s->output_buf_size)) < 0) {
+                    av_freep(&s->output_buf);
                     s->output_buf_size = 0;
                     goto end;
                 }
-                memcpy(s->output_buf + s->output_buf_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
-                s->output_buf_size += buffer->nFilledLen;
-                if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) {
-                    if ((ret = av_packet_from_data(pkt, s->output_buf, s->output_buf_size)) < 0) {
-                        av_freep(&s->output_buf);
-                        s->output_buf_size = 0;
-                        goto end;
-                    }
-                    s->output_buf = NULL;
-                    s->output_buf_size = 0;
-                }
-#if CONFIG_OMX_RPI
-                had_partial = 1;
-#endif
-            if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) {
+                s->output_buf = NULL;
+                s->output_buf_size = 0;
                 pkt->pts = av_rescale_q(from_omx_ticks(buffer->nTimeStamp), AV_TIME_BASE_Q, avctx->time_base);
                 // We don't currently enable B-frames for the encoders, so set
                 // pkt->dts = pkt->pts. (The calling code behaves worse if the encoder
@@ -891,6 +886,10 @@  static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                 if (buffer->nFlags & OMX_BUFFERFLAG_SYNCFRAME)
                     pkt->flags |= AV_PKT_FLAG_KEY;
                 *got_packet = 1;
+            } else {
+#if CONFIG_OMX_RPI
+                had_partial = 1;
+#endif
             }
         }
 end: