summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-29 23:38:40 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-06-08 12:52:49 +0200
commit964c826f5507978e76c4b9fe5f5ad976909f273e (patch)
tree7c3da339b88a50ffd96ade5728f1285e592f63f7
parenteeedc8817a8d7c1264fc952ffdbba501be3c679e (diff)
avcodec/omx: Reindentation
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>
-rw-r--r--libavcodec/omx.c33
1 files changed, 16 insertions, 17 deletions
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: