Permalink
Browse files

Removed calls to deprecated avcodec_alloc_frame and added first pass …

…of raw generator
  • Loading branch information...
srstrong committed Jan 26, 2014
1 parent 7d05c25 commit 00bc375236bc90f5c2a0be70bd3f85d999b645ec
Showing with 75 additions and 2 deletions.
  1. +1 −1 c_src/audio_encoded_input.c
  2. +1 −1 c_src/audio_raw_input.c
  3. +1 −0 c_src/filters.c
  4. +72 −0 c_src/video_raw_generator.c
@@ -84,7 +84,7 @@ static void init(ID3ASFilterContext *context, AVDictionary *codec_options)
this->codec = get_decoder(this->codec_name);
this->context = allocate_audio_context(this->codec, this->sample_rate, this->channel_layout, this->sample_format, codec_options);
- this->frame = avcodec_alloc_frame();
+ this->frame = av_frame_alloc();
}
static const AVOption options[] = {
View
@@ -53,7 +53,7 @@ static void init(ID3ASFilterContext *context, AVDictionary *codec_options)
this->num_channels = av_get_channel_layout_nb_channels(this->channel_layout);
this->bytes_per_sample = this->num_channels * av_get_bytes_per_sample(this->sample_format);
- this->frame = avcodec_alloc_frame();
+ this->frame = av_frame_alloc();
this->frame->format = this->sample_format;
this->frame->channel_layout = this->channel_layout;
}
View
@@ -24,6 +24,7 @@ void id3as_filters_register_all()
REGISTER_INPUT(encoded_audio);
REGISTER_INPUT(raw_video);
REGISTER_INPUT(encoded_video);
+ REGISTER_INPUT(raw_video_generator);
REGISTER_FILTER(resample_audio);
REGISTER_FILTER(rescale_video);
@@ -0,0 +1,72 @@
+#include "id3as_libav.h"
+
+typedef struct _codec_t
+{
+ AVClass *av_class;
+
+ AVFrame *frame;
+
+ char *device_name;
+ int width;
+ int height;
+ int interlaced;
+ int frame_rate;
+ enum PixelFormat pixfmt;
+
+} codec_t;
+
+static void process(ID3ASFilterContext *context,
+ unsigned char *metadata, unsigned int metadata_size,
+ unsigned char *opaque, unsigned int opaque_size,
+ unsigned char *data, unsigned int data_size)
+{
+ codec_t *this = context->priv_data;
+
+ avpicture_fill((AVPicture *) this->frame, data, this->pixfmt, this->width, this->height);
+
+ set_frame_metadata(this->frame, metadata);
+
+ send_to_graph(context, this->frame, NINETY_KHZ);
+}
+
+static void flush(ID3ASFilterContext *context)
+{
+ flush_graph(context);
+}
+
+static void init(ID3ASFilterContext *context, AVDictionary *codec_options)
+{
+ codec_t *this = context->priv_data;
+
+ this->frame = av_frame_alloc();
+ this->frame->format = this->pixfmt;
+ this->frame->width = this->width;
+ this->frame->height = this->height;
+ this->frame->interlaced_frame = this->interlaced ? 1 : 0;
+}
+
+static const AVOption options[] = {
+ { "device", "The codec for encoding", offsetof(codec_t, device_name), AV_OPT_TYPE_STRING },
+ { "width", "the width", offsetof(codec_t, width), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX },
+ { "height", "the height", offsetof(codec_t, height), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX },
+ { "interlaced", "is input interlaced format", offsetof(codec_t, interlaced), AV_OPT_TYPE_INT },
+ { "frame_rate", "frame rate", offsetof(codec_t, frame_rate), AV_OPT_TYPE_INT },
+ { "pixel_format", "the pixel format", offsetof(codec_t, pixfmt), AV_OPT_TYPE_INT },
+ { NULL }
+};
+
+static const AVClass class = {
+ .class_name = "raw video input options",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+ID3ASFilter id3as_raw_video_generator_input = {
+ .name = "raw video generator",
+ .init = init,
+ .execute = process,
+ .flush = flush,
+ .priv_data_size = sizeof(codec_t),
+ .priv_class = &class
+};

0 comments on commit 00bc375

Please sign in to comment.