]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec_jpeg.c
Merge commit '5956f489d0452ff6dea6b6b81b4fa8e596fc5684'
[ffmpeg] / libavformat / rtpdec_jpeg.c
index ccd80ad7e88cc3dc945a559537ed0e62133162e9..447ea2f6bef61ea9f7f67fcafa6274fcc610278f 100644 (file)
@@ -59,12 +59,7 @@ static const uint8_t default_quantizers[128] = {
     99,  99,  99,  99,  99,  99,  99,  99
 };
 
-static PayloadContext *jpeg_new_context(void)
-{
-    return av_mallocz(sizeof(PayloadContext));
-}
-
-static inline void free_frame_if_needed(PayloadContext *jpeg)
+static inline void free_frame(PayloadContext *jpeg)
 {
     if (jpeg->frame) {
         uint8_t *p;
@@ -76,7 +71,7 @@ static inline void free_frame_if_needed(PayloadContext *jpeg)
 
 static void jpeg_free_context(PayloadContext *jpeg)
 {
-    free_frame_if_needed(jpeg);
+    free_frame(jpeg);
     av_free(jpeg);
 }
 
@@ -338,7 +333,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
 
         /* Skip the current frame in case of the end packet
          * has been lost somewhere. */
-        free_frame_if_needed(jpeg);
+        free_frame(jpeg);
 
         if ((ret = avio_open_dyn_buf(&jpeg->frame)) < 0)
             return ret;
@@ -364,7 +359,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
     if (jpeg->timestamp != *timestamp) {
         /* Skip the current frame if timestamp is incorrect.
          * A start packet has been lost somewhere. */
-        free_frame_if_needed(jpeg);
+        free_frame(jpeg);
         av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match.\n");
         return AVERROR_INVALIDDATA;
     }
@@ -402,7 +397,7 @@ RTPDynamicProtocolHandler ff_jpeg_dynamic_handler = {
     .enc_name          = "JPEG",
     .codec_type        = AVMEDIA_TYPE_VIDEO,
     .codec_id          = AV_CODEC_ID_MJPEG,
-    .alloc             = jpeg_new_context,
+    .priv_data_size    = sizeof(PayloadContext),
     .free              = jpeg_free_context,
     .parse_packet      = jpeg_parse_packet,
     .static_payload_id = 26,