]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/nuv.c
Add a smooth streaming segmenter muxer
[ffmpeg] / libavformat / nuv.c
index bf596109e8b90ddde30f5ef41626a847b36f8d6a..fce96b420c15c68022aff5061088969c38d0ce43 100644 (file)
@@ -20,7 +20,9 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/intfloat.h"
 #include "avformat.h"
+#include "internal.h"
 #include "riff.h"
 
 typedef struct {
@@ -45,15 +47,15 @@ static int nuv_probe(AVProbeData *p) {
     return 0;
 }
 
-//! little macro to sanitize packet size
+/// little macro to sanitize packet size
 #define PKTSIZE(s) (s &  0xffffff)
 
 /**
- * \brief read until we found all data needed for decoding
- * \param vst video stream of which to change parameters
- * \param ast video stream of which to change parameters
- * \param myth set if this is a MythTVVideo format file
- * \return 1 if all required codec data was found
+ * @brief read until we found all data needed for decoding
+ * @param vst video stream of which to change parameters
+ * @param ast video stream of which to change parameters
+ * @param myth set if this is a MythTVVideo format file
+ * @return 1 if all required codec data was found
  */
 static int get_codec_data(AVIOContext *pb, AVStream *vst,
                           AVStream *ast, int myth) {
@@ -88,7 +90,7 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
                     vst->codec->codec_id =
                         ff_codec_get_id(ff_codec_bmp_tags, vst->codec->codec_tag);
                     if (vst->codec->codec_tag == MKTAG('R', 'J', 'P', 'G'))
-                        vst->codec->codec_id = CODEC_ID_NUV;
+                        vst->codec->codec_id = AV_CODEC_ID_NUV;
                 } else
                     avio_skip(pb, 4);
 
@@ -120,7 +122,7 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
     return 0;
 }
 
-static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
+static int nuv_header(AVFormatContext *s) {
     NUVContext *ctx = s->priv_data;
     AVIOContext *pb = s->pb;
     char id_string[12];
@@ -138,10 +140,10 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
     avio_rl32(pb); // unused, "desiredheight"
     avio_r8(pb); // 'P' == progressive, 'I' == interlaced
     avio_skip(pb, 3); // padding
-    aspect = av_int2dbl(avio_rl64(pb));
+    aspect = av_int2double(avio_rl64(pb));
     if (aspect > 0.9999 && aspect < 1.0001)
         aspect = 4.0 / 3.0;
-    fps = av_int2dbl(avio_rl64(pb));
+    fps = av_int2double(avio_rl64(pb));
 
     // number of packets per stream type, -1 means unknown, e.g. streaming
     v_packs = avio_rl32(pb);
@@ -152,38 +154,41 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
 
     if (v_packs) {
         ctx->v_id = stream_nr++;
-        vst = av_new_stream(s, ctx->v_id);
+        vst = avformat_new_stream(s, NULL);
         if (!vst)
             return AVERROR(ENOMEM);
         vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-        vst->codec->codec_id = CODEC_ID_NUV;
+        vst->codec->codec_id = AV_CODEC_ID_NUV;
         vst->codec->width = width;
         vst->codec->height = height;
         vst->codec->bits_per_coded_sample = 10;
         vst->sample_aspect_ratio = av_d2q(aspect * height / width, 10000);
-        vst->r_frame_rate = av_d2q(fps, 60000);
-        av_set_pts_info(vst, 32, 1, 1000);
+#if FF_API_R_FRAME_RATE
+        vst->r_frame_rate =
+#endif
+        vst->avg_frame_rate = av_d2q(fps, 60000);
+        avpriv_set_pts_info(vst, 32, 1, 1000);
     } else
         ctx->v_id = -1;
 
     if (a_packs) {
         ctx->a_id = stream_nr++;
-        ast = av_new_stream(s, ctx->a_id);
+        ast = avformat_new_stream(s, NULL);
         if (!ast)
             return AVERROR(ENOMEM);
         ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-        ast->codec->codec_id = CODEC_ID_PCM_S16LE;
+        ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
         ast->codec->channels = 2;
         ast->codec->sample_rate = 44100;
         ast->codec->bit_rate = 2 * 2 * 44100 * 8;
         ast->codec->block_align = 2 * 2;
         ast->codec->bits_per_coded_sample = 16;
-        av_set_pts_info(ast, 32, 1, 1000);
+        avpriv_set_pts_info(ast, 32, 1, 1000);
     } else
         ctx->a_id = -1;
 
     get_codec_data(pb, vst, ast, is_mythtv);
-    ctx->rtjpg_video = vst && vst->codec->codec_id == CODEC_ID_NUV;
+    ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV;
     return 0;
 }
 
@@ -258,13 +263,11 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
 }
 
 AVInputFormat ff_nuv_demuxer = {
-    "nuv",
-    NULL_IF_CONFIG_SMALL("NuppelVideo format"),
-    sizeof(NUVContext),
-    nuv_probe,
-    nuv_header,
-    nuv_packet,
-    NULL,
-    NULL,
-    .flags = AVFMT_GENERIC_INDEX,
+    .name           = "nuv",
+    .long_name      = NULL_IF_CONFIG_SMALL("NuppelVideo"),
+    .priv_data_size = sizeof(NUVContext),
+    .read_probe     = nuv_probe,
+    .read_header    = nuv_header,
+    .read_packet    = nuv_packet,
+    .flags          = AVFMT_GENERIC_INDEX,
 };