]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec_h263_rfc2190.c
configure: Document --enable-libfontconfig
[ffmpeg] / libavformat / rtpdec_h263_rfc2190.c
index 4957b337c7b96c8c928c443495a7252fdf5cbea8..019eea779b1626d6544f3d0c392f387bb195b490 100644 (file)
@@ -26,7 +26,9 @@
  */
 
 #include "avformat.h"
+#include "avio_internal.h"
 #include "rtpdec_formats.h"
+#include "libavutil/attributes.h"
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/get_bits.h"
 
@@ -38,26 +40,15 @@ struct PayloadContext {
     int          newformat;
 };
 
-static PayloadContext *h263_new_context(void)
+static void h263_close_context(PayloadContext *data)
 {
-    return av_mallocz(sizeof(PayloadContext));
-}
-
-static void h263_free_context(PayloadContext *data)
-{
-    if (!data)
-        return;
-    if (data->buf) {
-        uint8_t *p;
-        avio_close_dyn_buf(data->buf, &p);
-        av_free(p);
-    }
-    av_free(data);
+    ffio_free_dyn_buf(&data->buf);
 }
 
 static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
                               AVStream *st, AVPacket *pkt, uint32_t *timestamp,
-                              const uint8_t *buf, int len, int flags)
+                              const uint8_t *buf, int len, uint16_t seq,
+                              int flags)
 {
     /* Corresponding to header fields in the RFC */
     int f, p, i, sbit, ebit, src, r;
@@ -65,14 +56,12 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
 
     if (data->newformat)
         return ff_h263_handle_packet(ctx, data, st, pkt, timestamp, buf, len,
-                                     flags);
+                                     seq, flags);
 
     if (data->buf && data->timestamp != *timestamp) {
         /* Dropping old buffered, unfinished data */
-        uint8_t *p;
-        avio_close_dyn_buf(data->buf, &p);
-        av_free(p);
-        data->buf = NULL;
+        ffio_free_dyn_buf(&data->buf);
+        data->endbyte_bits = 0;
     }
 
     if (len < 4) {
@@ -118,11 +107,11 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
             /* Invalid src for this format, and bits that should be zero
              * according to RFC 2190 aren't zero. */
             av_log(ctx, AV_LOG_WARNING,
-                   "Interpreting H263 RTP data as RFC 2429/4629 even though "
+                   "Interpreting H.263 RTP data as RFC 2429/4629 even though "
                    "signalled with a static payload type.\n");
             data->newformat = 1;
             return ff_h263_handle_packet(ctx, data, st, pkt, timestamp, buf,
-                                         len, flags);
+                                         len, seq, flags);
         }
     }
 
@@ -197,8 +186,9 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
 RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler = {
     .codec_type        = AVMEDIA_TYPE_VIDEO,
     .codec_id          = AV_CODEC_ID_H263,
+    .need_parsing      = AVSTREAM_PARSE_FULL,
     .parse_packet      = h263_handle_packet,
-    .alloc             = h263_new_context,
-    .free              = h263_free_context,
+    .priv_data_size    = sizeof(PayloadContext),
+    .close             = h263_close_context,
     .static_payload_id = 34,
 };