avformat/filmstripenc: Use ff_raw_write_packet()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 7 Apr 2020 21:23:12 +0000 (23:23 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 14 Apr 2020 17:01:27 +0000 (19:01 +0200)
The only difference of the currently used write_packet()-function to
ff_raw_write_packet() is that the former also counts the number of
frames. Yet doing so in the muxer itself is unnecessary as this is
already done generically in write_packet() in libavformat/mux.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/Makefile
libavformat/filmstripenc.c

index 554b0bf..d4bed3c 100644 (file)
@@ -179,7 +179,7 @@ OBJS-$(CONFIG_FFMETADATA_MUXER)          += ffmetaenc.o
 OBJS-$(CONFIG_FIFO_MUXER)                += fifo.o
 OBJS-$(CONFIG_FIFO_TEST_MUXER)           += fifo_test.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER)         += filmstripdec.o
-OBJS-$(CONFIG_FILMSTRIP_MUXER)           += filmstripenc.o
+OBJS-$(CONFIG_FILMSTRIP_MUXER)           += filmstripenc.o rawenc.o
 OBJS-$(CONFIG_FITS_DEMUXER)              += fitsdec.o
 OBJS-$(CONFIG_FITS_MUXER)                += fitsenc.o
 OBJS-$(CONFIG_FLAC_DEMUXER)              += flacdec.o rawdec.o \
index 8ead696..83faf29 100644 (file)
 
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "rawenc.h"
 
 #define RAND_TAG MKBETAG('R','a','n','d')
 
-typedef struct FilmstripMuxContext {
-    int nb_frames;
-} FilmstripMuxContext;
-
 static int write_header(AVFormatContext *s)
 {
     if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
@@ -42,23 +39,14 @@ static int write_header(AVFormatContext *s)
     return 0;
 }
 
-static int write_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    FilmstripMuxContext *film = s->priv_data;
-    avio_write(s->pb, pkt->data, pkt->size);
-    film->nb_frames++;
-    return 0;
-}
-
 static int write_trailer(AVFormatContext *s)
 {
-    FilmstripMuxContext *film = s->priv_data;
     AVIOContext *pb = s->pb;
     AVStream *st = s->streams[0];
     int i;
 
     avio_wb32(pb, RAND_TAG);
-    avio_wb32(pb, film->nb_frames);
+    avio_wb32(pb, st->nb_frames);
     avio_wb16(pb, 0);  // packing method
     avio_wb16(pb, 0);  // reserved
     avio_wb16(pb, st->codecpar->width);
@@ -76,10 +64,9 @@ AVOutputFormat ff_filmstrip_muxer = {
     .name              = "filmstrip",
     .long_name         = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
     .extensions        = "flm",
-    .priv_data_size    = sizeof(FilmstripMuxContext),
     .audio_codec       = AV_CODEC_ID_NONE,
     .video_codec       = AV_CODEC_ID_RAWVIDEO,
     .write_header      = write_header,
-    .write_packet      = write_packet,
+    .write_packet      = ff_raw_write_packet,
     .write_trailer     = write_trailer,
 };