ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Sun Mar 30 12:06:13 2025 +0200| [35c091f4b7fb19aee9dfcc6c60ace0be92907ce5] | 
committer: Andreas Rheinhardt

avformat/rtpenc: Check dimensions during init

Also fixes a -Wdeclaration-after-statement warning.

Reviewed-by: Michael Niedermayer <mich...@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=35c091f4b7fb19aee9dfcc6c60ace0be92907ce5
---

 libavformat/rtpenc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 8b989dca71..b220a941a2 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -219,6 +219,14 @@ static int rtp_write_header(AVFormatContext *s1)
             s->nal_length_size = (st->codecpar->extradata[21] & 0x03) + 1;
         }
         break;
+    case AV_CODEC_ID_MJPEG:
+    case AV_CODEC_ID_BITPACKED:
+    case AV_CODEC_ID_RAWVIDEO:
+        if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
+            av_log(s1, AV_LOG_ERROR, "dimensions not set\n");
+            return AVERROR(EINVAL);
+        }
+        break;
     case AV_CODEC_ID_VP9:
         if (s1->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
             av_log(s, AV_LOG_ERROR,
@@ -635,18 +643,10 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket 
*pkt)
         rtp_send_ilbc(s1, pkt->data, size);
         break;
     case AV_CODEC_ID_MJPEG:
-        if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
-            av_log(s1, AV_LOG_ERROR, "dimensions not set\n");
-            return AVERROR(EINVAL);
-        }
         ff_rtp_send_jpeg(s1, pkt->data, size);
         break;
     case AV_CODEC_ID_BITPACKED:
     case AV_CODEC_ID_RAWVIDEO: {
-        if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
-            av_log(s1, AV_LOG_ERROR, "dimensions not set\n");
-            return AVERROR(EINVAL);
-        }
         int interlaced = st->codecpar->field_order != AV_FIELD_PROGRESSIVE;
 
         ff_rtp_send_raw_rfc4175(s1, pkt->data, size, interlaced, 0);

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to