summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--av/avCodec.cpp574
-rw-r--r--av/avCodec.h35
-rw-r--r--ffmpeg-fas/COPYING.GPL339
-rw-r--r--ffmpeg-fas/COPYING.LGPL504
-rw-r--r--ffmpeg-fas/README14
-rwxr-xr-xffmpeg-fas/build.sh9
-rw-r--r--ffmpeg-fas/ffmpeg_fas.c801
-rw-r--r--ffmpeg-fas/ffmpeg_fas.h109
-rw-r--r--ffmpeg-fas/private_errors.h28
-rw-r--r--ffmpeg-fas/seek_indices.c319
-rw-r--r--ffmpeg-fas/seek_indices.h94
-rwxr-xr-xffmpeg-fas/test/build.sh7
-rw-r--r--ffmpeg-fas/test/dump_frames.c67
-rw-r--r--ffmpeg-fas/test/dump_keyframes.c76
-rw-r--r--ffmpeg-fas/test/external_seek_test.c172
-rw-r--r--ffmpeg-fas/test/generate_seek_table.c209
-rw-r--r--ffmpeg-fas/test/movie_info.c81
-rwxr-xr-xffmpeg-fas/test/run_test.py56
-rw-r--r--ffmpeg-fas/test/seek_test.c162
-rw-r--r--ffmpeg-fas/test/show_seek_table.c59
-rw-r--r--ffmpeg-fas/test/test_support.h67
-rw-r--r--libavwrapper/Makefile251
-rwxr-xr-xlibavwrapper/libavwrapper.cpp755
-rwxr-xr-xlibavwrapper/libavwrapper.h150
-rwxr-xr-xlibavwrapper/unit_test.cpp14
-rwxr-xr-xlibavwrapper/unit_test.h3
-rwxr-xr-xmuxing/maker1
-rw-r--r--muxing/muxing.c508
-rw-r--r--opencv/Makefile253
-rw-r--r--opencv/cvimage.h265
-rw-r--r--opencv/hello-opencv.cpp68
-rw-r--r--opencv/hello-opencv.d196
-rw-r--r--opencv/hello-opencv.obin5560 -> 0 bytes
-rwxr-xr-xopencv/opencvbin12500 -> 0 bytes
-rw-r--r--processmodel/Makefile252
-rw-r--r--processmodel/processmodel.cpp296
-rw-r--r--processmodel/rendercontext_src/Makefile252
-rw-r--r--processmodel/rendercontext_src/rendercontext.cpp45
-rwxr-xr-xrotord/src/libavwrapper.cpp7
-rwxr-xr-xrotord/src/libavwrapper.h9
-rwxr-xr-xrotord/src/rotor.cpp30
-rwxr-xr-xrotord/src/rotor.h13
-rwxr-xr-xvaa3d_wrapper/libavwrapper.cpp739
-rwxr-xr-xvaa3d_wrapper/libavwrapper.h132
44 files changed, 47 insertions, 7974 deletions
diff --git a/av/avCodec.cpp b/av/avCodec.cpp
deleted file mode 100644
index 61c201b..0000000
--- a/av/avCodec.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-#include "avCodec.h"
-
-#define INBUF_SIZE 4096
-#define AUDIO_INBUF_SIZE 20480
-#define AUDIO_REFILL_THRESH 4096
-
-/* check that a given sample format is supported by the encoder */
-static int avCodec::check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt)
-{
- const enum AVSampleFormat *p = codec->sample_fmts;
-
- while (*p != AV_SAMPLE_FMT_NONE) {
- if (*p == sample_fmt)
- return 1;
- p++;
- }
- return 0;
-}
-
-/* just pick the highest supported samplerate */
-static int avCodec::select_sample_rate(AVCodec *codec)
-{
- const int *p;
- int best_samplerate = 0;
-
- if (!codec->supported_samplerates)
- return 44100;
-
- p = codec->supported_samplerates;
- while (*p) {
- best_samplerate = FFMAX(*p, best_samplerate);
- p++;
- }
- return best_samplerate;
-}
-
-/* select layout with the highest channel count */
-static int avCodec::select_channel_layout(AVCodec *codec)
-{
- const uint64_t *p;
- uint64_t best_ch_layout = 0;
- int best_nb_channells = 0;
-
- if (!codec->channel_layouts)
- return AV_CH_LAYOUT_STEREO;
-
- p = codec->channel_layouts;
- while (*p) {
- int nb_channels = av_get_channel_layout_nb_channels(*p);
-
- if (nb_channels > best_nb_channells) {
- best_ch_layout = *p;
- best_nb_channells = nb_channels;
- }
- p++;
- }
- return best_ch_layout;
-}
-
-/*
- * Audio encoding example
- */
-static void avCodec::audio_encode_example(const char *filename)
-{
- AVCodec *codec;
- AVCodecContext *c= NULL;
- AVFrame *frame;
- AVPacket pkt;
- int i, j, k, ret, got_output;
- int buffer_size;
- FILE *f;
- uint16_t *samples;
- float t, tincr;
-
- printf("Encode audio file %s\n", filename);
-
- /* find the MP2 encoder */
- codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
- if (!codec) {
- fprintf(stderr, "Codec not found\n");
- exit(1);
- }
-
- c = avcodec_alloc_context3(codec);
- if (!c) {
- fprintf(stderr, "Could not allocate audio codec context\n");
- exit(1);
- }
-
- /* put sample parameters */
- c->bit_rate = 64000;
-
- /* check that the encoder supports s16 pcm input */
- c->sample_fmt = AV_SAMPLE_FMT_S16;
- if (!check_sample_fmt(codec, c->sample_fmt)) {
- fprintf(stderr, "Encoder does not support sample format %s",
- av_get_sample_fmt_name(c->sample_fmt));
- exit(1);
- }
-
- /* select other audio parameters supported by the encoder */
- c->sample_rate = select_sample_rate(codec);
- c->channel_layout = select_channel_layout(codec);
- c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
-
- /* open it */
- if (avcodec_open2(c, codec, NULL) < 0) {
- fprintf(stderr, "Could not open codec\n");
- exit(1);
- }
-
- f = fopen(filename, "wb");
- if (!f) {
- fprintf(stderr, "Could not open %s\n", filename);
- exit(1);
- }
-
- /* frame containing input raw audio */
- frame = avcodec_alloc_frame();
- if (!frame) {
- fprintf(stderr, "Could not allocate audio frame\n");
- exit(1);
- }
-
- frame->nb_samples = c->frame_size;
- frame->format = c->sample_fmt;
- frame->channel_layout = c->channel_layout;
-
- /* the codec gives us the frame size, in samples,
- * we calculate the size of the samples buffer in bytes */
- buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
- c->sample_fmt, 0);
- samples = (uint16_t*)av_malloc(buffer_size);
- if (!samples) {
- fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
- buffer_size);
- exit(1);
- }
- /* setup the data pointers in the AVFrame */
- ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
- (const uint8_t*)samples, buffer_size, 0);
- if (ret < 0) {
- fprintf(stderr, "Could not setup audio frame\n");
- exit(1);
- }
-
- /* encode a single tone sound */
- t = 0;
- tincr = 2 * M_PI * 440.0 / c->sample_rate;
- for(i=0;i<200;i++) {
- av_init_packet(&pkt);
- pkt.data = NULL; // packet data will be allocated by the encoder
- pkt.size = 0;
-
- for (j = 0; j < c->frame_size; j++) {
- samples[2*j] = (int)(sin(t) * 10000);
-
- for (k = 1; k < c->channels; k++)
- samples[2*j + k] = samples[2*j];
- t += tincr;
- }
- /* encode the samples */
- ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
- if (ret < 0) {
- fprintf(stderr, "Error encoding audio frame\n");
- exit(1);
- }
- if (got_output) {
- fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
- }
- }
-
- /* get the delayed frames */
- for (got_output = 1; got_output; i++) {
- ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
- if (ret < 0) {
- fprintf(stderr, "Error encoding frame\n");
- exit(1);
- }
-
- if (got_output) {
- fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
- }
- }
- fclose(f);
-
- av_freep(&samples);
- avcodec_free_frame(&frame);
- avcodec_close(c);
- av_free(c);
-}
-
-/*
- * Audio decoding.
- */
-static void avCodec::audio_decode_example(const char *outfilename, const char *filename)
-{
- AVCodec *codec;
- AVCodecContext *c= NULL;
- int len;
- FILE *f, *outfile;
- uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
- AVPacket avpkt;
- AVFrame *decoded_frame = NULL;
-
- av_init_packet(&avpkt);
-
- printf("Decode audio file %s to %s\n", filename, outfilename);
-
- /* find the mpeg audio decoder */
- codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
- if (!codec) {
- fprintf(stderr, "Codec not found\n");
- exit(1);
- }
-
- c = avcodec_alloc_context3(codec);
- if (!c) {
- fprintf(stderr, "Could not allocate audio codec context\n");
- exit(1);
- }
-
- /* open it */
- if (avcodec_open2(c, codec, NULL) < 0) {
- fprintf(stderr, "Could not open codec\n");
- exit(1);
- }
-
- f = fopen(filename, "rb");
- if (!f) {
- fprintf(stderr, "Could not open %s\n", filename);
- exit(1);
- }
- outfile = fopen(outfilename, "wb");
- if (!outfile) {
- av_free(c);
- exit(1);
- }
-
- /* decode until eof */
- avpkt.data = inbuf;
- avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
-
- while (avpkt.size > 0) {
- int got_frame = 0;
-
- if (!decoded_frame) {
- if (!(decoded_frame = avcodec_alloc_frame())) {
- fprintf(stderr, "Could not allocate audio frame\n");
- exit(1);
- }
- } else
- avcodec_get_frame_defaults(decoded_frame);
-
- len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
- if (len < 0) {
- fprintf(stderr, "Error while decoding\n");
- exit(1);
- }
- if (got_frame) {
- /* if a frame has been decoded, output it */
- int data_size = av_samples_get_buffer_size(NULL, c->channels,
- decoded_frame->nb_samples,
- c->sample_fmt, 1);
- fwrite(decoded_frame->data[0], 1, data_size, outfile);
- }
- avpkt.size -= len;
- avpkt.data += len;
- avpkt.dts =
- avpkt.pts = AV_NOPTS_VALUE;
- if (avpkt.size < AUDIO_REFILL_THRESH) {
- /* Refill the input buffer, to avoid trying to decode
- * incomplete frames. Instead of this, one could also use
- * a parser, or use a proper container format through
- * libavformat. */
- memmove(inbuf, avpkt.data, avpkt.size);
- avpkt.data = inbuf;
- len = fread(avpkt.data + avpkt.size, 1,
- AUDIO_INBUF_SIZE - avpkt.size, f);
- if (len > 0)
- avpkt.size += len;
- }
- }
-
- fclose(outfile);
- fclose(f);
-
- avcodec_close(c);
- av_free(c);
- avcodec_free_frame(&decoded_frame);
-}
-
-/*
- * Video encoding example
- */
-static void avCodec::video_encode_example(const char *filename, int codec_id)
-{
- AVCodec *codec;
- AVCodecContext *c= NULL;
- int i, ret, x, y, got_output;
- FILE *f;
- AVFrame *frame;
- AVPacket pkt;
- uint8_t endcode[] = { 0, 0, 1, 0xb7 };
-
- printf("Encode video file %s\n", filename);
-
- /* find the mpeg1 video encoder */
- codec =avcodec_find_encoder(codec_id);
- if (!codec) {
- fprintf(stderr, "Codec not found\n");
- exit(1);
- }
-
- c = avcodec_alloc_context3(codec);
- if (!c) {
- fprintf(stderr, "Could not allocate video codec context\n");
- exit(1);
- }
-
- /* put sample parameters */
- c->bit_rate = 400000;
- /* resolution must be a multiple of two */
- c->width = 352;
- c->height = 288;
- /* frames per second */
- c->time_base= (AVRational){1,25};
- c->gop_size = 10; /* emit one intra frame every ten frames */
- c->max_b_frames=1;
- c->pix_fmt = AV_PIX_FMT_YUV420P;
-
- if(codec_id == AV_CODEC_ID_H264)
- av_opt_set(c->priv_data, "preset", "slow", 0);
-
- /* open it */
- if (avcodec_open2(c, codec, NULL) < 0) {
- fprintf(stderr, "Could not open codec\n");
- exit(1);
- }
-
- f = fopen(filename, "wb");
- if (!f) {
- fprintf(stderr, "Could not open %s\n", filename);
- exit(1);
- }
-
- frame = avcodec_alloc_frame();
- if (!frame) {
- fprintf(stderr, "Could not allocate video frame\n");
- exit(1);
- }
- frame->format = c->pix_fmt;
- frame->width = c->width;
- frame->height = c->height;
-
- /* the image can be allocated by any means and av_image_alloc() is
- * just the most convenient way if av_malloc() is to be used */
- ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
- c->pix_fmt, 32);
- if (ret < 0) {
- fprintf(stderr, "Could not allocate raw picture buffer\n");
- exit(1);
- }
-
- /* encode 1 second of video */
- for(i=0;i<25;i++) {
- av_init_packet(&pkt);
- pkt.data = NULL; // packet data will be allocated by the encoder
- pkt.size = 0;
-
- fflush(stdout);
- /* prepare a dummy image */
- /* Y */
- for(y=0;y<c->height;y++) {
- for(x=0;x<c->width;x++) {
- frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
- }
- }
-
- /* Cb and Cr */
- for(y=0;y<c->height/2;y++) {
- for(x=0;x<c->width/2;x++) {
- frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
- frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
- }
- }
-
- frame->pts = i;
-
- /* encode the image */
- ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
- if (ret < 0) {
- fprintf(stderr, "Error encoding frame\n");
- exit(1);
- }
-
- if (got_output) {
- printf("Write frame %3d (size=%5d)\n", i, pkt.size);
- fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
- }
- }
-
- /* get the delayed frames */
- for (got_output = 1; got_output; i++) {
- fflush(stdout);
-
- ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
- if (ret < 0) {
- fprintf(stderr, "Error encoding frame\n");
- exit(1);
- }
-
- if (got_output) {
- printf("Write frame %3d (size=%5d)\n", i, pkt.size);
- fwrite(pkt.data, 1, pkt.size, f);
- av_free_packet(&pkt);
- }
- }
-
- /* add sequence end code to have a real mpeg file */
- fwrite(endcode, 1, sizeof(endcode), f);
- fclose(f);
-
- avcodec_close(c);
- av_free(c);
- av_freep(&frame->data[0]);
- avcodec_free_frame(&frame);
- printf("\n");
-}
-
-/*
- * Video decoding example
- */
-
-static void avCodec::pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
- char *filename)
-{
- FILE *f;
- int i;
-
- f=fopen(filename,"w");
- fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
- for(i=0;i<ysize;i++)
- fwrite(buf + i * wrap,1,xsize,f);
- fclose(f);
-}
-
-static int avCodec::decode_write_frame(const char *outfilename, AVCodecContext *avctx,
- AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
-{
- int len, got_frame;
- char buf[1024];
-
- len = avcodec_decode_video2(avctx, frame, &got_frame, pkt);
- if (len < 0) {
- fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
- return len;
- }
- if (got_frame) {
- printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);
- fflush(stdout);
-
- /* the picture is allocated by the decoder, no need to free it */
- snprintf(buf, sizeof(buf), outfilename, *frame_count);
- pgm_save(frame->data[0], frame->linesize[0],
- avctx->width, avctx->height, buf);
- (*frame_count)++;
- }
- if (pkt->data) {
- pkt->size -= len;
- pkt->data += len;
- }
- return 0;
-}
-
-static void avCodec::video_decode_example(const char *outfilename, const char *filename)
-{
- AVCodec *codec;
- AVCodecContext *c= NULL;
- int frame_count;
- FILE *f;
- AVFrame *frame;
- uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
- AVPacket avpkt;
-
- av_init_packet(&avpkt);
-
- /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
- memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
- printf("Decode video file %s to %s\n", filename, outfilename);
-
- /* find the mpeg1 video decoder */
- codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
- if (!codec) {
- fprintf(stderr, "Codec not found\n");
- exit(1);
- }
-
- c = avcodec_alloc_context3(codec);
- if (!c) {
- fprintf(stderr, "Could not allocate video codec context\n");
- exit(1);
- }
-
- if(codec->capabilities&CODEC_CAP_TRUNCATED)
- c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
-
- /* For some codecs, such as msmpeg4 and mpeg4, width and height
- MUST be initialized there because this information is not
- available in the bitstream. */
-
- /* open it */
- if (avcodec_open2(c, codec, NULL) < 0) {
- fprintf(stderr, "Could not open codec\n");
- exit(1);
- }
-
- f = fopen(filename, "rb");
- if (!f) {
- fprintf(stderr, "Could not open %s\n", filename);
- exit(1);
- }
-
- frame = avcodec_alloc_frame();
- if (!frame) {
- fprintf(stderr, "Could not allocate video frame\n");
- exit(1);
- }
-
- frame_count = 0;
- for(;;) {
- avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
- if (avpkt.size == 0)
- break;
-
- /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
- and this is the only method to use them because you cannot
- know the compressed data size before analysing it.
-
- BUT some other codecs (msmpeg4, mpeg4) are inherently frame
- based, so you must call them with all the data for one
- frame exactly. You must also initialize 'width' and
- 'height' before initializing them. */
-
- /* NOTE2: some codecs allow the raw parameters (frame size,
- sample rate) to be changed at any frame. We handle this, so
- you should also take care of it */
-
- /* here, we use a stream based decoder (mpeg1video), so we
- feed decoder and see if it could decode a frame */
- avpkt.data = inbuf;
- while (avpkt.size > 0)
- if (decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 0) < 0)
- exit(1);
- }
-
- /* some codecs, such as MPEG, transmit the I and P frame with a
- latency of one frame. You must do the following to have a
- chance to get the last frame of the video */
- avpkt.data = NULL;
- avpkt.size = 0;
- decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);
-
- fclose(f);
-
- avcodec_close(c);
- av_free(c);
- avcodec_free_frame(&frame);
- printf("\n");
-} \ No newline at end of file
diff --git a/av/avCodec.h b/av/avCodec.h
deleted file mode 100644
index 7e1815a..0000000
--- a/av/avCodec.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// libav includes
-// from /usr/include
-
-extern "C" {
- #ifndef __STDC_CONSTANT_MACROS
- # define __STDC_CONSTANT_MACROS
- #endif
-
- #ifndef UINT64_C
- #define UINT64_C(c) (c ## ULL)
- #endif
-
- #include <math.h>
-
- #include "libavcodec/avcodec.h"
-
- #include "libavutil/opt.h"
- #include "libavutil/channel_layout.h"
- #include "libavutil/common.h"
- #include "libavutil/imgutils.h"
- #include "libavutil/mathematics.h"
- #include "libavutil/samplefmt.h"
-}
-
-namespace avCodec {
- static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt);
- static int select_sample_rate(AVCodec *codec);
- static int select_channel_layout(AVCodec *codec);
- static void audio_encode_example(const char *filename);
- static void audio_decode_example(const char *outfilename, const char *filename);
- static void video_encode_example(const char *filename, int codec_id);
- static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,char *filename);
- static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,AVFrame *frame, int *frame_count, AVPacket *pkt, int last);
- static void video_decode_example(const char *outfilename, const char *filename);
-} \ No newline at end of file
diff --git a/ffmpeg-fas/COPYING.GPL b/ffmpeg-fas/COPYING.GPL
deleted file mode 100644
index d159169..0000000
--- a/ffmpeg-fas/COPYING.GPL
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/ffmpeg-fas/COPYING.LGPL b/ffmpeg-fas/COPYING.LGPL
deleted file mode 100644
index 00b4fed..0000000
--- a/ffmpeg-fas/COPYING.LGPL
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/ffmpeg-fas/README b/ffmpeg-fas/README
deleted file mode 100644
index 6cb5e32..0000000
--- a/ffmpeg-fas/README
+++ /dev/null
@@ -1,14 +0,0 @@
-The frame-accurate seek library extension to ffmpeg requires ffmpeg.
-Getting the most recent version of ffmpeg and building it from source is
-recommended:
-
-svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
-
-The test/example build script requires ffmpeg be checked out (or symlinked)
-from the base directory.
-
-Features:
-1) Simplified interface for video processing
-2) Frame-accurate seeking using a seek-table
-3) Online creation of a seek-table through normal decoding
-4) Saving and loading of seek-tables. \ No newline at end of file
diff --git a/ffmpeg-fas/build.sh b/ffmpeg-fas/build.sh
deleted file mode 100755
index 0550dc7..0000000
--- a/ffmpeg-fas/build.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-cd `dirname $0`
-FFMPEG_BASEDIR=../libavstuff/ffmpeg/
-
-rm -rf lib
-mkdir lib
-
-gcc ffmpeg_fas.c seek_indices.c -I$FFMPEG_BASEDIR ffmpeg/libavformat/libavformat.a ffmpeg/libavcodec/libavcodec.a ffmpeg/libavutil/libavutil.a -O2 -shared -o lib/libffmpeg_fas.so
-gcc -c ffmpeg_fas.c seek_indices.c -O2 -I$FFMPEG_BASEDIR
-ar rc lib/libffmpeg_fas.a ffmpeg_fas.o seek_indices.o
diff --git a/ffmpeg-fas/ffmpeg_fas.c b/ffmpeg-fas/ffmpeg_fas.c
deleted file mode 100644
index 38a614c..0000000
--- a/ffmpeg-fas/ffmpeg_fas.c
+++ /dev/null
@@ -1,801 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include "ffmpeg_fas.h"
-#include "libavformat/avformat.h"
-#include "libavcodec/avcodec.h"
-#include "seek_indices.h"
-#include "private_errors.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-
-#define FIRST_FRAME_INDEX 0
-#define NUM_POSSIBLE_ERRORS 9
-
-/**** Private Types ***********************************************************/
-
-typedef struct fas_context_struct {
- fas_boolean_type is_video_active;
- fas_boolean_type is_frame_available;
-
- int current_frame_index;
-
- seek_table_type seek_table;
-
- /* ffmpeg */
- AVFormatContext *format_context;
- AVCodecContext *codec_context;
- int stream_idx;
-
- AVFrame *frame_buffer; // internal buffer
-
- AVFrame *rgb_frame_buffer; // extra AVFrames (for color conversion)
- uint8_t *rgb_buffer; // actual data buffer for rgb_frame_buffer (needs to be freed seperately)
- fas_boolean_type rgb_already_converted; // color_convert(frame_buffer) == rgb_frame_buffer (so we don't need to repeat conversions)
-
- AVFrame *gray8_frame_buffer;
- uint8_t *gray8_buffer;
- fas_boolean_type gray8_already_converted;
-
- int64_t current_dts; // decoding timestamp of the most recently parsed packet
- int64_t previous_dts; // for previous packet (always use previous packet for seek_table (workaround))
- int64_t keyframe_packet_dts; // dts of most recent keyframe packet
- int64_t first_dts; // for very first packet (needed in seek, for first keyframe)
-
-} fas_context_type;
-
-static char* invalid_error_code = "not a valid error code";
-static char *gbl_error_strings[NUM_POSSIBLE_ERRORS] =
-{
- "fas_success",
- "fas_failure",
- "fas_invalid_argument",
- "fas_out_of_memory",
- "fas_unsupported_format",
- "fas_unsupported_codec",
- "fas_no_more_frames",
- "fas_decoding_error",
- "fas_seek_error"
-};
-
-char* fas_error_message(fas_error_type error)
-{
- if ((error < 0) || (error >= NUM_POSSIBLE_ERRORS))
- return invalid_error_code;
-
- return gbl_error_strings[error];
-}
-
-static void private_show_warning (const char *message);
-static fas_error_type private_show_error (const char *message, fas_error_type error);
-static fas_error_type private_convert_to_rgb (fas_context_ref_type ctx);
-static fas_error_type private_seek_to_nearest_key (fas_context_ref_type context, int target_index, int offset);
-fas_error_type private_complete_seek_table (fas_context_ref_type context);
-
-
-void fas_set_logging (fas_boolean_type logging)
-{
- if (logging == FAS_TRUE)
- {
- SHOW_ERROR_MESSAGES = 1;
- SHOW_WARNING_MESSAGES = 1;
- av_log_level = AV_LOG_INFO;
- }
- else
- {
- SHOW_ERROR_MESSAGES = 0;
- SHOW_WARNING_MESSAGES = 0;
- av_log_level = AV_LOG_QUIET;
- }
-}
-
-void fas_initialize (fas_boolean_type logging)
-{
- fas_set_logging(logging);
- av_register_all();
-
- return;
-}
-
-/* fas_open_video */
-
-fas_error_type fas_open_video (fas_context_ref_type *context_ptr, char *file_path)
-{
- if (NULL == context_ptr)
- return private_show_error ("NULL context pointer provided", FAS_INVALID_ARGUMENT);
-
- // seek_error_type seek_error;
- fas_context_ref_type fas_context;
-
- *context_ptr = NULL; // set returned context to NULL in case of error
-
- fas_context = (fas_context_ref_type)malloc (sizeof (fas_context_type));
- memset(fas_context, 0, sizeof(fas_context_type));
-
- if (NULL == fas_context)
- return private_show_error ("unable to allocate buffer", FAS_OUT_OF_MEMORY);
-
- fas_context->is_video_active = FAS_TRUE;
- fas_context->is_frame_available = FAS_TRUE;
- fas_context->current_frame_index = FIRST_FRAME_INDEX - 1;
- fas_context->current_dts = AV_NOPTS_VALUE;
- fas_context->previous_dts = AV_NOPTS_VALUE;
- fas_context->keyframe_packet_dts = AV_NOPTS_VALUE;
- fas_context->first_dts = AV_NOPTS_VALUE;
-
- fas_context->seek_table = seek_init_table (-1); /* default starting size */
-
- if (av_open_input_file ( &(fas_context->format_context), file_path, NULL, 0, NULL ) != 0)
- {
- fas_close_video(fas_context);
- return private_show_error ("failure to open file", FAS_UNSUPPORTED_FORMAT);
- }
-
- if (av_find_stream_info (fas_context->format_context) < 0)
- {
- fas_close_video(fas_context);
- return private_show_error ("could not extract stream information", FAS_UNSUPPORTED_FORMAT);
- }
-
- if (SHOW_WARNING_MESSAGES)
- dump_format(fas_context->format_context, 0, file_path, 0);
-
- int stream_idx;
- for (stream_idx = 0; stream_idx < fas_context->format_context->nb_streams; stream_idx++)
- {
- if (fas_context->format_context->streams[stream_idx]->codec->codec_type == CODEC_TYPE_VIDEO)
- {
- fas_context->stream_idx = stream_idx;
- fas_context->codec_context = fas_context->format_context->streams[stream_idx]->codec;
- break;
- }
- }
-
- if (fas_context->codec_context == 0)
- {
- fas_close_video(fas_context);
- return private_show_error ("failure to find a video stream", FAS_UNSUPPORTED_FORMAT);
- }
-
- AVCodec *codec = avcodec_find_decoder (fas_context->codec_context->codec_id);
-
- if (!codec)
- {
- fas_context->codec_context = 0;
- fas_close_video(fas_context);
- return private_show_error("failed to find correct video codec", FAS_UNSUPPORTED_CODEC);
- }
-
- if (avcodec_open (fas_context->codec_context, codec) < 0)
- {
- fas_context->codec_context = 0;
- fas_close_video(fas_context);
- return private_show_error ("failed to open codec", FAS_UNSUPPORTED_CODEC);
- }
-
- fas_context->frame_buffer = avcodec_alloc_frame ();
- if (fas_context->frame_buffer == NULL)
- {
- fas_close_video(fas_context);
- return private_show_error ("failed to allocate frame buffer", FAS_OUT_OF_MEMORY);
- }
-
- fas_context->rgb_frame_buffer = avcodec_alloc_frame ();
- if (fas_context->rgb_frame_buffer == NULL)
- {
- fas_close_video(fas_context);
- return private_show_error ("failed to allocate rgb frame buffer", FAS_OUT_OF_MEMORY);
- }
-
- fas_context->gray8_frame_buffer = avcodec_alloc_frame ();
- if (fas_context->gray8_frame_buffer == NULL)
- {
- fas_close_video(fas_context);
- return private_show_error ("failed to allocate gray8 frame buffer", FAS_OUT_OF_MEMORY);
- }
-
- fas_context->rgb_buffer = 0;
- fas_context->gray8_buffer = 0;
- fas_context->rgb_already_converted = FAS_FALSE;
- fas_context->gray8_already_converted = FAS_FALSE;
-
- *context_ptr = fas_context;
-
-
- if (FAS_SUCCESS != fas_step_forward(*context_ptr))
- return private_show_error ("failure decoding first frame", FAS_NO_MORE_FRAMES);
-
- if (!fas_frame_available(*context_ptr))
- return private_show_error ("couldn't find a first frame (no valid frames in video stream)", FAS_NO_MORE_FRAMES);
-
-
-
- return FAS_SUCCESS;
-}
-
-/* fas_close_video */
-fas_error_type fas_close_video (fas_context_ref_type context)
-{
- if (NULL == context)
- return private_show_error ("NULL context provided for fas_close_video()", FAS_INVALID_ARGUMENT);
-
- if (!(context->is_video_active))
- {
- private_show_warning ("Redundant attempt to close an inactive video");
- return FAS_SUCCESS;
- }
-
- if (context->codec_context)
- if (avcodec_find_decoder (context->codec_context->codec_id))
- avcodec_close(context->codec_context);
-
- if (context->format_context)
- av_close_input_file (context->format_context);
-
- if (context->rgb_frame_buffer)
- av_free (context->rgb_frame_buffer);
-
- if (context->gray8_frame_buffer)
- av_free (context->gray8_frame_buffer);
-
- if (context->rgb_buffer)
- av_free(context->rgb_buffer);
-
- if (context->gray8_buffer)
- av_free(context->gray8_buffer);
-
- if (context->frame_buffer)
- av_free (context->frame_buffer);
-
- seek_release_table (&(context->seek_table));
-
- context->is_video_active = FAS_FALSE;
-
- free (context);
-
- return FAS_SUCCESS;
-}
-
-
-/* fas_step_forward */
-fas_error_type fas_step_forward (fas_context_ref_type context)
-{
- if ((NULL == context) || (FAS_TRUE != context->is_video_active)) {
- return private_show_error ("invalid or unopened context", FAS_INVALID_ARGUMENT);
- }
-
- if (!context->is_frame_available)
- {
- private_show_warning ("tried to advance after end of frames");
- return FAS_SUCCESS;
- }
-
- context->current_frame_index++;
-
- AVPacket packet;
- while (FAS_TRUE)
- {
- if (av_read_frame(context->format_context, &packet) < 0)
- {
- /* finished */
- context->is_frame_available = FAS_FALSE;
- context->seek_table.completed = seek_true;
- return FAS_SUCCESS;
- }
-
- int frameFinished;
- if (packet.stream_index == context->stream_idx)
- {
- context->previous_dts = context->current_dts;
- context->current_dts = packet.dts;
-
- /* seek support: set first_dts */
- if (context->first_dts == AV_NOPTS_VALUE)
- context->first_dts = packet.dts;
-
- /* seek support: set key-packet info to previous packet's dts, when possible */
- /* note this -1 approach to setting the packet is a workaround for a common failure. setting
- to 0 would work just incur a huge penalty in videos that needed -1. Might be worth testing.
- */
- if (packet.flags & PKT_FLAG_KEY)
- {
- //fprintf(stderr, "Packet: (F:%d %lld %lld)\n", context->current_frame_index, packet.pts, packet.dts);
-
- if (context->previous_dts == AV_NOPTS_VALUE)
- context->keyframe_packet_dts = packet.dts;
- else
- context->keyframe_packet_dts = context->previous_dts;
- }
-
- avcodec_decode_video(context->codec_context, context->frame_buffer, &frameFinished,
- packet.data, packet.size);
-
- if (frameFinished)
- {
- /* seek support: (try to) add entry to seek_table */
- if (context->frame_buffer->key_frame)
- {
- // fprintf(stderr, "Frame : (PXX F%d: %lld %lld)\n", context->current_frame_index, packet.pts, packet.dts);
-
- seek_entry_type entry;
- entry.display_index = context->current_frame_index;
- entry.first_packet_dts = context->keyframe_packet_dts;
- entry.last_packet_dts = packet.dts;
-
- if (fas_get_frame_index(context) == FIRST_FRAME_INDEX)
- entry.first_packet_dts = context->first_dts;
-
- seek_append_table_entry(&context->seek_table, entry);
- }
-
- if (context->current_frame_index - FIRST_FRAME_INDEX + 1 > context->seek_table.num_frames)
- context->seek_table.num_frames = context->current_frame_index - FIRST_FRAME_INDEX + 1;
-
- break;
- }
- }
-
- av_free_packet(&packet);
- }
-
- context->rgb_already_converted = FAS_FALSE;
- context->gray8_already_converted = FAS_FALSE;
- av_free_packet(&packet);
- return FAS_SUCCESS;
-}
-
-/* fas_get_frame_index */
-
-int fas_get_frame_index (fas_context_ref_type context)
-{
- if (NULL == context)
- return private_show_error ("NULL context provided for fas_get_frame_index()", FAS_INVALID_ARGUMENT);
-
- if (FAS_TRUE != context->is_video_active)
- return private_show_error ("No video is open for fas_get_frame_index()", FAS_INVALID_ARGUMENT);
-
- return context->current_frame_index;
-}
-
-
-/* fas_get_frame */
-
-fas_error_type fas_get_frame (fas_context_ref_type context, fas_raw_image_type *image_ptr)
-{
- int buffer_size;
- fas_error_type fas_error;
-
- if (NULL == context || FAS_FALSE == context->is_video_active)
- return private_show_error ("null context or inactive video", FAS_INVALID_ARGUMENT);
-
- if (NULL == image_ptr)
- return private_show_error ("null image_ptr on get_frame", FAS_INVALID_ARGUMENT);
-
- if (!fas_frame_available(context))
- return private_show_error ("no frame available for extraction", FAS_NO_MORE_FRAMES);
-
- memset (image_ptr, 0, sizeof (fas_raw_image_type));
-
- buffer_size = context->codec_context->width * context->codec_context->height * 3;
-
- image_ptr->data = (unsigned char *)malloc (buffer_size);
- if (NULL == image_ptr->data)
- return private_show_error ("unable to allocate space for RGB image", FAS_OUT_OF_MEMORY);
-
- image_ptr->color_space = FAS_RGB24;
- image_ptr->width = context->codec_context->width;
- image_ptr->height = context->codec_context->height;
- image_ptr->bytes_per_line = context->codec_context->width * 3;
-
-
- fas_error = private_convert_to_rgb(context);
-
- int j;
- unsigned char *from;
- unsigned char *to;
- for (j=0;j<context->codec_context->height; j++)
- {
- from = context->rgb_frame_buffer->data[0] + j*context->rgb_frame_buffer->linesize[0];
- to = image_ptr->data + j*image_ptr->bytes_per_line;
-
- memcpy(to, from, context->codec_context->width *3);
- }
-
- if (FAS_SUCCESS != fas_error)
- return private_show_error ("unable to convert image to RGB", FAS_FAILURE);
-
- return FAS_SUCCESS;
-}
-
-/* fas_free_frame */
-
-void fas_free_frame (fas_raw_image_type image)
-{
- if (NULL == image.data)
- return;
-
- free (image.data);
-
- return;
-}
-
-/* fas_get_seek_table */
-seek_table_type fas_get_seek_table (fas_context_ref_type context)
-{
- seek_table_type null_table;
-
- null_table.array = NULL;
- null_table.completed = seek_false;
- null_table.num_frames = -1;
- null_table.num_entries = 0;
- null_table.allocated_size = 0;
-
- if (NULL == context || FAS_FALSE == context->is_video_active)
- return null_table;
-
- return context->seek_table;
-}
-
-/* fas_put_seek_table */
-fas_error_type fas_put_seek_table (fas_context_ref_type context, seek_table_type table)
-{
- if (NULL == context || FAS_FALSE == context->is_video_active)
- return private_show_error ("null context or inactive video", FAS_INVALID_ARGUMENT);
-
- seek_release_table (&context->seek_table);
- context->seek_table = seek_copy_table(table);
-
- return FAS_SUCCESS;
-}
-
-/* private_complete_seek_table */
-fas_error_type private_complete_seek_table (fas_context_ref_type context)
-{
- if ((NULL == context) || (FAS_FALSE == context->is_video_active))
- return private_show_error ("invalid or unopened context", FAS_INVALID_ARGUMENT);
-
- if (context->seek_table.completed)
- return FAS_SUCCESS;
-
- fas_error_type fas_error = fas_seek_to_nearest_key (context, context->seek_table.num_frames + FIRST_FRAME_INDEX - 1);
- if (FAS_SUCCESS != fas_error)
- return private_show_error("failed when trying to complete seek table (1) (first frame not labeled keyframe?)", fas_error);
-
- while (fas_frame_available(context))
- {
- // printf("%d\n", context->seek_table.num_frames);
- fas_step_forward(context);
- }
-
- if (!context->seek_table.completed)
- return private_show_error("failed when trying to complete seek table (2)", FAS_SEEK_ERROR);
-
- return FAS_SUCCESS;
-}
-
-/* fas_seek_to_frame */
-fas_error_type fas_seek_to_frame (fas_context_ref_type context, int target_index)
-{
-
- fas_error_type fas_error;
-
- if ((NULL == context) || (FAS_FALSE == context->is_video_active))
- return private_show_error ("invalid or unopened context", FAS_INVALID_ARGUMENT);
-
- // printf("seeking to %d (from %d)!\n", target_index, context->current_frame_index);
- if (target_index == context->current_frame_index)
- return FAS_SUCCESS;
-
- fas_error = fas_seek_to_nearest_key (context, target_index);
-
- if (fas_error != FAS_SUCCESS)
- return private_show_error ("error advancing to key frame before seek", fas_error);
-
- if (fas_get_frame_index(context) > target_index)
- return private_show_error ("error advancing to key frame before seek (index isn't right)", fas_error);
-
- while (fas_get_frame_index(context) < target_index)
- {
- if (fas_frame_available(context))
- fas_step_forward(context);
- else
- return private_show_error ("error advancing to request frame (probably out of range)", FAS_SEEK_ERROR);
- }
-
-
- return FAS_SUCCESS;
-}
-
-/* fas_seek_to_nearest_key */
-
-fas_error_type fas_seek_to_nearest_key (fas_context_ref_type context, int target_index)
-{
- return private_seek_to_nearest_key(context, target_index,0);
-}
-
-/* private_seek_to_nearest_key */
-
-fas_error_type private_seek_to_nearest_key (fas_context_ref_type context, int target_index, int offset)
-{
- if ((NULL == context) || (FAS_TRUE != context->is_video_active))
- return private_show_error ("invalid or unopened context", FAS_INVALID_ARGUMENT);
-
- // printf("HERE: from: %d to: %d offset: %d\n", context->current_frame_index, target_index, offset);
- fas_error_type fas_error;
- seek_entry_type seek_entry;
- seek_error_type seek_error = seek_get_nearest_entry (&(context->seek_table), &seek_entry, target_index, offset);
-
- if (seek_error != seek_no_error)
- return private_show_error ("error while searching seek table", FAS_SEEK_ERROR);
-
- if (seek_entry.display_index == context->current_frame_index)
- return FAS_SUCCESS;
-
- // printf("HERE: from: %d to: %d (%d) offset: %d\n", context->current_frame_index, target_index, seek_entry.display_index, offset);
- // printf("trying to seek to %d (%lld->%lld)\n", seek_entry.display_index, seek_entry.first_packet_dts, seek_entry.last_packet_dts);
-
- // if something goes terribly wrong, return bad current_frame_index
- context->current_frame_index = -2;
- context->is_frame_available = FAS_TRUE;
-
- int flags = 0;
- if (seek_entry.first_packet_dts <= context->current_dts)
- flags = AVSEEK_FLAG_BACKWARD;
-
- // printf("av_seek_frame: %lld\n", seek_entry.first_packet_dts);
- if (av_seek_frame(context->format_context, context->stream_idx, seek_entry.first_packet_dts, flags) < 0)
- return private_show_error("seek to keyframe failed", FAS_SEEK_ERROR);
-
-
- avcodec_flush_buffers (context->codec_context);
-
- fas_error = fas_step_forward (context);
-
- if (fas_error != FAS_SUCCESS || !context->is_frame_available)
- {
- // something bad has happened, try previous keyframe
- private_show_warning("processing of seeked keyframe failed, trying previous keyframe");
- return private_seek_to_nearest_key(context, target_index, offset + 1);
- }
-
- while (context->current_dts < seek_entry.last_packet_dts)
- {
- //printf("frame-times: current: %lld target: %lld is_key: %d\n", context->current_dts, seek_entry.last_packet_dts, context->frame_buffer->key_frame);
- fas_error = fas_step_forward(context);
- if (fas_error != FAS_SUCCESS)
- return private_show_error ("unable to process up to target frame (fas_seek_to_frame)", fas_error);
- }
-
- // printf("keyframe vitals: %d looking_for: %lld at: %lld\n", seek_entry.display_index, seek_entry.last_packet_dts, context->current_dts);
- if (context->current_dts != seek_entry.last_packet_dts)
- {
- /* seek to last key-frame, but look for this one */
- private_show_warning("missed keyframe, trying previous keyframe");
- return private_seek_to_nearest_key(context, target_index, offset + 1);
- }
-
- /* Ideally, we could just check if the frame decoded is of the correct time stamp... but... we need several ugly workarounds:
-
- 1) Some videos have bad keyframes that don't get decoded properly. In this cases, we need to go back a keyframe.
-
- 2) Other times, none of the frames are labeled keyframes. In these cases, we need to allow seeking to frame 0
- even when it's not labeled as a keyframe. Messy set of conditions.
- */
-
- if ((!context->frame_buffer->key_frame) && (seek_entry.display_index != 0))
- {
- private_show_warning("found keyframe, but not labeled as keyframe, so trying previous keyframe.");
- /* seek & look for previous keyframe */
- /* REMOVE FROM TABLE? */
- return private_seek_to_nearest_key(context, seek_entry.display_index - 1, 0);
- }
-
- context->current_frame_index = seek_entry.display_index;
-
- return FAS_SUCCESS;
-}
-
-/* fas_get_frame_count */
-
-int fas_get_frame_count_fast (fas_context_ref_type context)
-{
-
- if (NULL == context || FAS_FALSE == context->is_video_active)
- {
- private_show_error ("NULL or invalid context", FAS_INVALID_ARGUMENT);
- return -1;
- }
-
- if (context->seek_table.completed == seek_true)
- return context->seek_table.num_frames;
-
- return -1;
-}
-
-int fas_get_frame_count (fas_context_ref_type context)
-{
- int fast = fas_get_frame_count_fast(context);
- if (fast >= 0)
- return fast;
-
- int current_frame = fas_get_frame_index(context);
-
- fas_error_type fas_error;
-
- fas_error = private_complete_seek_table(context);
- if (FAS_SUCCESS != fas_error)
- {
- private_show_error("failed in get_frame_count trying to complete the seek table", fas_error);
- return -1;
- }
-
- // seek_show_raw_table(stderr, context->seek_table);
-
- fas_error = fas_seek_to_frame(context, current_frame);
- if (FAS_SUCCESS != fas_error)
- {
- private_show_error("failed in get_frame_count when trying to seek back to original location", fas_error);
- return -1;
- }
-
- fast = fas_get_frame_count_fast(context);
- if (fast < 0)
- private_show_warning("get_frame_count failed");
-
- return fast;
-}
-
-/* fas_frame_available */
-
-fas_boolean_type fas_frame_available (fas_context_ref_type context)
-{
- if (NULL == context)
- {
- private_show_error ("NULL context provided for fas_get_frame_index()", FAS_INVALID_ARGUMENT);
- return FAS_FALSE;
- }
-
- if (!context->is_video_active)
- return FAS_FALSE;
-
- return context->is_frame_available;
-}
-
-
-/* private_show_error */
-
-static fas_error_type private_show_error (const char *message, fas_error_type error)
-{
- if (SHOW_ERROR_MESSAGES)
- fprintf (stderr, " ===> ffmpeg_fas: %s\n", message);
- return error;
-}
-
-static void private_show_warning (const char *message)
-{
- if (SHOW_WARNING_MESSAGES)
- fprintf (stderr, " ---- ffmpeg_fas: %s\n", message);
- return;
-}
-
-
-/* private_convert_to_rgb */
-
-fas_error_type private_convert_to_rgb (fas_context_ref_type ctx)
-{
- if (ctx->rgb_already_converted)
- return FAS_SUCCESS;
-
- if (ctx->rgb_buffer == 0)
- {
- int numBytes = avpicture_get_size(PIX_FMT_RGB24, ctx->codec_context->width,
- ctx->codec_context->height);
- ctx->rgb_buffer = (uint8_t *) av_malloc(numBytes*sizeof(uint8_t));
- avpicture_fill((AVPicture *) ctx->rgb_frame_buffer, ctx->rgb_buffer, PIX_FMT_RGB24,
- ctx->codec_context->width, ctx->codec_context->height);
- }
-
- if (img_convert((AVPicture *) ctx->rgb_frame_buffer, PIX_FMT_RGB24, (AVPicture *) ctx->frame_buffer,
- ctx->codec_context->pix_fmt,
- ctx->codec_context->width, ctx->codec_context->height) < 0)
- private_show_error("error converting to rgb", FAS_DECODING_ERROR);
-
- ctx->rgb_already_converted = FAS_TRUE;
-
- return FAS_SUCCESS;
-}
-
-
-/* private_convert_to_gray8 */
-
-fas_error_type private_convert_to_gray8 (fas_context_ref_type ctx)
-{
- if (ctx->gray8_already_converted)
- return FAS_SUCCESS;
-
- if (ctx->gray8_buffer == 0)
- {
- int numBytes = avpicture_get_size(PIX_FMT_GRAY8, ctx->codec_context->width,
- ctx->codec_context->height);
- ctx->gray8_buffer = (uint8_t *) av_malloc(numBytes*sizeof(uint8_t));
- avpicture_fill((AVPicture *) ctx->gray8_frame_buffer, ctx->gray8_buffer, PIX_FMT_GRAY8,
- ctx->codec_context->width, ctx->codec_context->height);
- }
-
- if (img_convert((AVPicture *) ctx->gray8_frame_buffer, PIX_FMT_GRAY8, (AVPicture *) ctx->frame_buffer,
- ctx->codec_context->pix_fmt,
- ctx->codec_context->width, ctx->codec_context->height) < 0)
- private_show_error("error converting to gray8", FAS_DECODING_ERROR);
-
- ctx->gray8_already_converted = FAS_TRUE;
-
- return FAS_SUCCESS;
-}
-
-int fas_get_current_width(fas_context_ref_type context)
-{
- return context->codec_context->width;
-}
-
-int fas_get_current_height(fas_context_ref_type context)
-{
- return context->codec_context->height;
-}
-
-fas_error_type fas_fill_gray8_ptr(fas_context_ref_type context, unsigned char *y)
-{
- /* this conversion also seems to screw up sometimes -- pal8 -> gray8? legodragon.avi */
- if (private_convert_to_gray8(context) != FAS_SUCCESS)
- return FAS_FAILURE;
-
- int width = context->codec_context->width;
- int height = context->codec_context->height;
- int i;
- for (i=0;i < height; i++)
- memcpy(y + width * i, context->gray8_frame_buffer->data[0] + context->gray8_frame_buffer->linesize[0] * i, width);
-
- return FAS_SUCCESS;
-}
-
-fas_error_type fas_fill_420p_ptrs (fas_context_ref_type context, unsigned char *y, unsigned char *u, unsigned char *v)
-{
- AVFrame *p = context->frame_buffer;
-
- /* 411p to 420p conversion fails!? ... so i left this -ldb */
- if (context->codec_context->pix_fmt != PIX_FMT_YUV420P)
- return FAS_FAILURE;
-
- int width = context->codec_context->width;
- int height = context->codec_context->height;
- int i;
- for (i=0;i < height / 2; i++)
- {
- memcpy(y + width * (2*i) , p->data[0] + p->linesize[0] * (2*i) , width);
- memcpy(y + width * (2*i + 1), p->data[0] + p->linesize[0] * (2*i + 1), width);
- memcpy(u + width / 2 * i, p->data[1] + p->linesize[1] * i, width / 2);
- memcpy(v + width / 2 * i, p->data[2] + p->linesize[2] * i, width / 2);
- }
-
- return FAS_SUCCESS;
-}
diff --git a/ffmpeg-fas/ffmpeg_fas.h b/ffmpeg-fas/ffmpeg_fas.h
deleted file mode 100644
index 3e8be94..0000000
--- a/ffmpeg-fas/ffmpeg_fas.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#ifndef FFMPEG_FAS_H
-#define FFMPEG_FAS_H
-
-/* If C++ then we need to __extern "C". Compiler defines __cplusplus */
-#ifdef __cplusplus
-#define __extern extern "C"
-#else
-#define __extern extern
-#endif
-
-#include "seek_indices.h"
-
-typedef enum
-{
- FAS_GRAY8 = 1,
- FAS_RGB24 = 2,
- FAS_ARGB32 = 3,
-} fas_color_space_type;
-
-typedef struct
-{
- unsigned char *data;
- int width;
- int height;
- int bytes_per_line;
- fas_color_space_type color_space;
-} fas_raw_image_type;
-
-
-/**********************************************************************
- * Video IO Types
- **********************************************************************/
-
-typedef struct fas_context_struct* fas_context_ref_type;
-
-typedef enum
-{
- FAS_SUCCESS,
- FAS_FAILURE,
- FAS_INVALID_ARGUMENT,
- FAS_OUT_OF_MEMORY,
- FAS_UNSUPPORTED_FORMAT,
- FAS_UNSUPPORTED_CODEC,
- FAS_NO_MORE_FRAMES,
- FAS_DECODING_ERROR,
- FAS_SEEK_ERROR,
-} fas_error_type;
-
-typedef enum
-{
- FAS_FALSE = 0,
- FAS_TRUE = 1
-} fas_boolean_type;
-
-
-__extern void fas_initialize (fas_boolean_type logging);
-
-__extern fas_error_type fas_open_video (fas_context_ref_type *context_ptr, char *file_path);
-__extern fas_error_type fas_close_video (fas_context_ref_type context);
-
-__extern char* fas_error_message (fas_error_type error);
-
-__extern fas_boolean_type fas_frame_available (fas_context_ref_type context);
-__extern int fas_get_frame_index (fas_context_ref_type context);
-__extern fas_error_type fas_step_forward (fas_context_ref_type context);
-
-__extern fas_error_type fas_get_frame (fas_context_ref_type context, fas_raw_image_type *image_ptr);
-__extern void fas_free_frame (fas_raw_image_type image);
-
-__extern fas_error_type fas_seek_to_nearest_key (fas_context_ref_type context, int target_index);
-__extern fas_error_type fas_seek_to_frame (fas_context_ref_type context, int target_index);
-
-__extern int fas_get_frame_count (fas_context_ref_type context);
-__extern int fas_get_frame_count_fast (fas_context_ref_type context);
-
-__extern fas_error_type fas_put_seek_table (fas_context_ref_type context, seek_table_type table);
-__extern seek_table_type fas_get_seek_table (fas_context_ref_type context);
-
-/* will extract raw 420p if the video is in that format -- needs to be alloced ahead of time*/
-__extern fas_error_type fas_fill_420p_ptrs (fas_context_ref_type context, unsigned char *y, unsigned char *u, unsigned char *v);
-
-/* will extract gray8 data from movie (will convert to ensure you get it) -- need to be alloc'ed ahead of time*/
-__extern fas_error_type fas_fill_gray8_ptr(fas_context_ref_type context, unsigned char *y);
-
-__extern int fas_get_current_width(fas_context_ref_type context);
-__extern int fas_get_current_height(fas_context_ref_type context);
-
-#endif
diff --git a/ffmpeg-fas/private_errors.h b/ffmpeg-fas/private_errors.h
deleted file mode 100644
index b68f7d2..0000000
--- a/ffmpeg-fas/private_errors.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#ifndef FAS_PRIVATE_ERROR_H
-#define FAS_PRIVATE_ERROR_H
-
-int SHOW_ERROR_MESSAGES;
-int SHOW_WARNING_MESSAGES;
-
-#endif
diff --git a/ffmpeg-fas/seek_indices.c b/ffmpeg-fas/seek_indices.c
deleted file mode 100644
index 63d2b23..0000000
--- a/ffmpeg-fas/seek_indices.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "seek_indices.h"
-#include "private_errors.h"
-
-/**** Defines *****************************************************************/
-
-#define DEFAULT_INITIAL_SIZE 100
-
-static seek_error_type private_show_error (const char *message, seek_error_type error);
-static seek_error_type private_resize_table (seek_table_type *table, int new_size);
-
-
-/*
- * seek_init_table
- */
-
-int compare_seek_tables(seek_table_type t1, seek_table_type t2)
-{
- int i;
-
- // printf("n_entries=(%d %d)\n", t1.num_entries, t2.num_entries);
-
- if (t1.num_entries != t2.num_entries)
- return 0;
-
- if (t1.completed != t2.completed)
- return 0;
-
- if (t1.num_frames != t2.num_frames)
- return 0;
-
- for (i=0;i<t1.num_entries;i++)
- {
- // printf("(%d %d) (%lld %lld) (%lld %lld)\n",
- // t1.array[i].display_index, t2.array[i].display_index,
- // t1.array[i].decode_time, t2.array[i].decode_time,
- // t1.array[i].display_time, t2.array[i].display_time);
- if ((t1.array[i].display_index != t2.array[i].display_index) ||
- (t1.array[i].last_packet_dts != t2.array[i].last_packet_dts) ||
- (t1.array[i].first_packet_dts != t2.array[i].first_packet_dts))
- return 0;
- }
-
- return 1;
-}
-
-seek_table_type seek_init_table (int initial_size)
-{
- seek_table_type table;
-
- if (initial_size < 0)
- initial_size = DEFAULT_INITIAL_SIZE;
-
- table.num_entries = 0;
- table.num_frames = -1;
- table.completed = seek_false;
-
- table.array = (seek_entry_type *)malloc (initial_size * sizeof(seek_entry_type));
-
- if (NULL == table.array)
- table.allocated_size = 0;
- else
- table.allocated_size = initial_size;
-
- return table;
-}
-
-/*
- * seek_release_table
- */
-
-void seek_release_table (seek_table_type *table)
-{
- table->num_entries = 0;
- table->num_frames = -1;
- table->completed = seek_false;
-
- if (NULL == table || NULL == table->array)
- return;
-
- free (table->array);
- return;
-}
-
-/*
- * seek_copy_table
- */
-
-seek_table_type seek_copy_table (seek_table_type source)
-{
- seek_table_type dest;
- dest.num_entries = source.num_entries;
- dest.num_frames = source.num_frames;
- dest.completed = source.completed;
-
- if (NULL == source.array)
- {
- dest.array = NULL;
- dest.allocated_size = 0;
- return dest;
- }
-
- dest.array = (seek_entry_type *)malloc (source.num_entries * sizeof(seek_entry_type));
-
- if (NULL == dest.array)
- {
- dest.array = NULL;
- dest.allocated_size = 0;
- return dest;
- }
-
- dest.allocated_size = source.num_entries;
-
- int i;
- for (i=0;i<source.num_entries;i++)
- dest.array[i] = source.array[i];
-
- return dest;
-}
-
-seek_error_type seek_append_table_entry (seek_table_type *table, seek_entry_type entry)
-{
-
- if (NULL == table || NULL == table->array)
- return private_show_error("null or invalid seek table", seek_bad_argument);
-
- if (table->num_entries != 0)
- if (table->array[table->num_entries - 1].display_index >= entry.display_index)
- return seek_no_error;
-
- if (table->num_entries == table->allocated_size)
- {
- seek_error_type error = private_resize_table (table, table->num_entries * 2);
- if (error != seek_no_error)
- return private_show_error ("unable to resize seek table", error);
- }
-
- table->array[table->num_entries] = entry;
- table->num_entries++;
-
- return seek_no_error;
-}
-
-/*
- * seek_get_nearest_entry
- */
-
-seek_error_type seek_get_nearest_entry (seek_table_type *table, seek_entry_type *entry, int display_index, int offset)
-{
- /* using offset>0 returns a modified seek_entry that sets the 'time-to-seek' to be $offset keyframes in the past.
- */
-
- if (NULL == table || NULL == table->array || table->num_entries <= 0) {
- return private_show_error ("NULL or invalid seek table", seek_bad_argument);
- }
-
- if (NULL == entry) {
- return private_show_error ("NULL entry buffer (for return)", seek_bad_argument);
- }
-
- if (display_index < table->array[0].display_index)
- return private_show_error ("tried to seek to frame index before first frame", seek_bad_argument);
-
- int i;
- for (i=0; i < table->num_entries; i++)
- if (table->array[i].display_index > display_index)
- break;
-
- i = i-1;
-
- if (i<offset) /* target was lower than first element (including offset) */
- return private_show_error ("target index out of table range (too small)", seek_bad_argument);
-
- *entry = table->array[i];
- (*entry).first_packet_dts = table->array[i-offset].first_packet_dts;
-
- return seek_no_error;
-}
-
-
-/* read raw file */
-seek_table_type read_table_file(char *name)
-{
- seek_table_type ans = { NULL, 0, 0 };
-
- FILE *table_file = fopen(name, "r");
- if (table_file == NULL)
- return ans;
-
- int completed_flag;
- fscanf(table_file, "%d %d %d\n", &ans.num_frames, &ans.num_entries, &completed_flag);
-
- if (completed_flag == 1)
- ans.completed = seek_true;
- else
- ans.completed = seek_false;
-
- ans.allocated_size = ans.num_entries;
- ans.array = malloc (ans.allocated_size * sizeof(seek_entry_type));
-
- int i;
- for (i=0;i<ans.num_entries;i++)
- fscanf(table_file, "%d %lld %lld\n", &(ans.array[i].display_index), &(ans.array[i].first_packet_dts), &(ans.array[i].last_packet_dts));
-
- fclose(table_file);
- return ans;
-}
-
-seek_error_type seek_show_raw_table (FILE* file, seek_table_type table)
-{
- seek_entry_type *entry;
- int index;
-
- if (NULL == table.array || table.num_entries <= 0)
- return private_show_error ("NULL or invalid seek table", seek_bad_argument);
-
- int completed_flag = 0;
- if (table.completed == seek_true)
- completed_flag = 1;
-
- fprintf(file, "%d %d %d\n", table.num_frames, table.num_entries, completed_flag);
- for (index = 0; index < table.num_entries; index++)
- {
- entry = &(table.array[index]);
-
- fprintf (file, "%d %lld %lld\n", entry->display_index, entry->first_packet_dts, entry->last_packet_dts);
- }
- return seek_no_error;
-}
-
-seek_error_type seek_show_table (seek_table_type table)
-{
- seek_entry_type *entry;
- int index;
-
- if (NULL == table.array || table.num_entries <= 0) {
- return private_show_error ("NULL or invalid seek table", seek_bad_argument);
- }
-
- int completed_flag = 0;
- if (table.completed == seek_true)
- completed_flag = 1;
-
- fprintf (stderr, "--- Seek Table Dump ---\n");
- fprintf (stderr, "n_frames: %d n_entries: %d completed: %d\n",table.num_frames, table.num_entries, completed_flag);
- for (index = 0; index < table.num_entries; index++)
- {
- entry = &(table.array[index]);
-
- fprintf (stderr, " %04d --> %08lld (%08lld)\n", entry->display_index, entry->first_packet_dts, entry->last_packet_dts);
- }
-
- fprintf (stderr, "-----------------------\n");
-
- return seek_no_error;
-}
-
-/*
- * private_show_error
- */
-
-static seek_error_type private_show_error (const char *message, seek_error_type error)
-{
- if (SHOW_ERROR_MESSAGES)
- fprintf (stderr, " ===> seek_indices: %s\n", message);
-
- return error;
-}
-
-/*
- * private_resize_table
- */
-
-static seek_error_type private_resize_table (seek_table_type *table, int new_size)
-{
- seek_entry_type *new_array = NULL;
-
- if (table == NULL || new_size < 0) {
- return private_show_error ("invalid argument for private_resize_table()", seek_malloc_failed);
- }
-
- new_array = (seek_entry_type *)malloc (sizeof (seek_entry_type) * new_size);
- if (NULL == new_array) {
- return private_show_error ("unable to allocate more space for table", seek_malloc_failed);
- }
-
- memcpy (new_array, table->array, table->allocated_size * sizeof (seek_entry_type));
- free (table->array);
-
- table->allocated_size = new_size;
- table->array = new_array;
-
- return seek_no_error;
-}
diff --git a/ffmpeg-fas/seek_indices.h b/ffmpeg-fas/seek_indices.h
deleted file mode 100644
index e908979..0000000
--- a/ffmpeg-fas/seek_indices.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#ifndef FAS_SEEK_INDICES_H
-#define FAS_SEEK_INDICES_H
-
-#include <stdint.h>
-#include <stdio.h>
-
-/* If C++ then we need to __extern "C". Compiler defines __cplusplus */
-#ifdef __cplusplus
-#define __extern extern "C"
-#else
-#define __extern extern
-#endif
-
-
-/**********************************************************************
- * Seek Table Types
- **********************************************************************/
-
-typedef enum
-{
- seek_no_error,
- seek_unknown_error,
- seek_bad_argument,
- seek_malloc_failed,
-} seek_error_type;
-
-typedef enum
-{
- seek_false = 0,
- seek_true = 1
-} seek_boolean_type;
-
-typedef struct
-{
- int display_index;
- int64_t first_packet_dts;
- int64_t last_packet_dts;
-} seek_entry_type;
-
-typedef struct
-{
- seek_entry_type *array;
- seek_boolean_type completed;
- int num_frames; // total number of frames
- int num_entries; // ie, number of seek-points (keyframes)
- int allocated_size;
-} seek_table_type;
-
-
-
-/**********************************************************************
- * Seek Table Functions
- **********************************************************************/
-
-
-__extern seek_table_type seek_init_table (int initial_size);
-__extern void seek_release_table (seek_table_type *table);
-
-__extern seek_table_type seek_copy_table (seek_table_type source);
-__extern int compare_seek_tables(seek_table_type t1, seek_table_type t2);
-
-__extern seek_error_type seek_append_table_entry (seek_table_type *table, seek_entry_type entry);
-
-__extern seek_error_type seek_get_nearest_entry (seek_table_type *table, seek_entry_type *entry, int display_index, int offset);
-
-__extern seek_error_type seek_show_table (seek_table_type table); /* human readable */
-__extern seek_error_type seek_show_raw_table (FILE *file, seek_table_type table);
-
-__extern seek_table_type read_table_file(char *name); /* read raw file */
-
-#endif
-
-/**** End of File *****************************************************/
diff --git a/ffmpeg-fas/test/build.sh b/ffmpeg-fas/test/build.sh
deleted file mode 100755
index d00dd63..0000000
--- a/ffmpeg-fas/test/build.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-LINK="../lib/libffmpeg_fas.so -lm -lz "
-gcc dump_frames.c -I.. $LINK -o dump_frames
-gcc dump_keyframes.c -I.. $LINK -o dump_keyframes
-gcc show_seek_table.c -I.. $LINK -o show_seek_table
-gcc seek_test.c -I.. $LINK -o seek_test
-gcc external_seek_test.c -I.. $LINK -o external_seek_test
-gcc generate_seek_table.c -I.. -I../ffmpeg/ ../ffmpeg/libavformat/libavformat.a ../ffmpeg/libavutil/libavutil.a ../ffmpeg/libavcodec/libavcodec.a -lm -lz ../lib/libffmpeg_fas.so -o generate_seek_table \ No newline at end of file
diff --git a/ffmpeg-fas/test/dump_frames.c b/ffmpeg-fas/test/dump_frames.c
deleted file mode 100644
index 6b4ccb7..0000000
--- a/ffmpeg-fas/test/dump_frames.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include "ffmpeg_fas.h"
-#include "test_support.h"
-#include <stdio.h>
-
-int main (int argc, char **argv)
-{
- char filename_buffer [255];
-
- fas_error_type video_error;
- fas_context_ref_type context;
- fas_raw_image_type image_buffer;
-
- if (argc < 2) {
- fprintf (stderr, "usage: %s <video_file>\n", argv[0]);
- return -1;
- }
-
- fas_initialize (FAS_FALSE);
-
- fprintf(stderr, "%s : ",argv[1]);
- video_error = fas_open_video (&context, argv[1]);
- if (video_error != FAS_SUCCESS)
- fail("failed to open\n");
-
- int counter = 0;
- while (fas_frame_available (context))
- {
-
- if (FAS_SUCCESS != fas_get_frame (context, &image_buffer))
- fail("failed on rgb image\n");
-
- char filename[50];
- sprintf(filename, "frame_%04d.ppm", counter);
-
- fprintf(stderr, "Writing %s (counter=%d frame_index=%d)\n", filename, counter, fas_get_frame_index(context));
- ppm_save(&image_buffer, filename);
-
- fas_free_frame (image_buffer);
-
- video_error = fas_step_forward (context);
- counter++;
- }
-
- success();
-
-}
diff --git a/ffmpeg-fas/test/dump_keyframes.c b/ffmpeg-fas/test/dump_keyframes.c
deleted file mode 100644
index 4e1333e..0000000
--- a/ffmpeg-fas/test/dump_keyframes.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include "ffmpeg_fas.h"
-#include "seek_indices.h"
-#include "test_support.h"
-#include <stdio.h>
-
-int main (int argc, char **argv)
-{
- fas_error_type video_error;
- fas_context_ref_type context, seek_context;
-
- if (argc < 3) {
- fprintf (stderr, "usage: %s <video_file> <seek_table>\n", argv[0]);
- fail("arguments\n");
- }
-
- seek_table_type table = read_table_file(argv[2]);
- if (table.num_entries == 0)
- fail("bad table\n");
-
- fas_initialize (FAS_TRUE);
-
- video_error = fas_open_video (&context, argv[1]);
- if (video_error != FAS_SUCCESS) fail("fail on open\n");
-
- video_error = fas_put_seek_table(context, table);
- if (video_error != FAS_SUCCESS) fail("fail on put_seek_table\n");
-
- video_error = fas_open_video (&seek_context, argv[1]);
- if (video_error != FAS_SUCCESS) fail("fail on open\n");
-
- int i;
- for(i=0;i<table.num_entries;i++)
- {
- // int frame_index = table.array[table.num_entries - i - 1].display_index;
- int frame_index = table.array[i].display_index;
- if (FAS_SUCCESS != fas_seek_to_frame(context, frame_index))
- fail("failed on seek");
-
- fas_raw_image_type image_buffer;
-
- if (FAS_SUCCESS != fas_get_frame (context, &image_buffer))
- fail("failed on rgb image\n");
-
- char filename[50];
- sprintf(filename, "frame_%04d.ppm", frame_index);
-
- fprintf(stderr, "Writing %s (seek_table_value=%d frame_index=%d)\n", filename, frame_index, fas_get_frame_index(context));
- ppm_save(&image_buffer, filename);
-
- fas_free_frame (image_buffer);
- }
-
- success();
-}
-
diff --git a/ffmpeg-fas/test/external_seek_test.c b/ffmpeg-fas/test/external_seek_test.c
deleted file mode 100644
index d81c141..0000000
--- a/ffmpeg-fas/test/external_seek_test.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-/* test seek using external table */
-
-#include "ffmpeg_fas.h"
-#include "seek_indices.h"
-#include "test_support.h"
-#include <stdio.h>
-
-#define TEST_SET_SIZE 1000
-#define N_ITERATIONS 500
-
-int compare_frames(fas_raw_image_type img1, fas_raw_image_type img2)
-{
- // printf("(%d %d) (%d %d) (%d %d) (%d %d)\n", img1.width, img2.width,
- // img1.height, img2.height,
- // img1.bytes_per_line, img2.bytes_per_line,
- // img1.color_space, img2.color_space);
-
- if ((img1.width != img2.width) ||
- (img1.height != img2.height) ||
- (img1.bytes_per_line != img2.bytes_per_line) ||
- (img1.color_space != img2.color_space))
- return 0;
-
- int i,j;
- int mask = 0;
-
- for (i=0;i<img1.height;i++)
- for(j=0;j<img1.bytes_per_line;j++)
- {
- //printf("%d ", (img1.data[i*img1.bytes_per_line+j] - img2.data[i*img1.bytes_per_line+j+j]));
- mask |= (img1.data[i*img1.bytes_per_line+j] - img2.data[i*img1.bytes_per_line+j]);
- }
-
- if (mask == 0)
- return 1;
- else
- return 0;
-}
-
-void do_random_test(fas_context_ref_type context, int start, int stop, int count)
-{
- // printf ("start: %d stop: %d\n", start, stop );
-
- while (fas_get_frame_index(context) < start)
- if (FAS_SUCCESS != fas_step_forward(context))
- fail("failed on advancement\n");
-
- fas_raw_image_type *ref_frames = malloc( (stop - start + 1)* sizeof(fas_raw_image_type));
-
- int i;
- fas_error_type video_error;
-
- while (fas_get_frame_index(context) <= stop)
- {
- i = fas_get_frame_index(context) - start;
-
- video_error = fas_get_frame(context, &(ref_frames[i]));
- if (video_error != FAS_SUCCESS) fail("fail on test(1)\n");
-
- video_error = fas_step_forward(context);
- if (video_error != FAS_SUCCESS) fail("fail on test(2)\n");
-
- }
-
- int index = -1;
- int prev_index;
-
- for (i=0;i<count;i++)
- {
- int offset = random() % (stop - start + 1);
- prev_index = index;
- index = start + offset;
-
- video_error = fas_seek_to_frame(context, index);
- if (video_error != FAS_SUCCESS) fail("fail on test(seek)\n");
-
-
- fas_raw_image_type test_frame;
- video_error = fas_get_frame(context, &test_frame);
- if (video_error != FAS_SUCCESS) fail("fail on test(seek2)\n");
-
- // printf("offset: %d / %d\n", offset, stop - start + 1);
-
- if (!compare_frames(test_frame, ref_frames[offset]))
- {
- char buffer[70];
-
- sprintf(buffer, "fail-%d-test.ppm", index);
- ppm_save(&test_frame, buffer);
- sprintf(buffer, "fail-%d-ref.ppm", index);
- ppm_save(&ref_frames[offset], buffer);
- sprintf(buffer, "failed on compare after seeking (%d->%d)\n", prev_index, index);
-
- fail(buffer);
- }
-
- fas_free_frame(test_frame);
- }
-
- for (i=0;i<stop - start + 1;i++)
- free(ref_frames[i].data);
-
- free(ref_frames);
-}
-
-int main (int argc, char **argv)
-{
- fas_error_type video_error;
- fas_context_ref_type context;
-
- if (argc < 3) {
- fprintf (stderr, "usage: %s <video_file> <seek_table>\n", argv[0]);
- fail("arguments\n");
- }
-
- fprintf(stderr, "%s : ", argv[1]);
-
- seek_table_type table = read_table_file(argv[2]);
- if (table.num_entries == 0)
- fail("bad table\n");
-
- fas_initialize (FAS_FALSE);
-
- video_error = fas_open_video (&context, argv[1]);
- if (video_error != FAS_SUCCESS) fail("fail on open\n");
-
- video_error = fas_put_seek_table(context, table);
- if (video_error != FAS_SUCCESS) fail("fail on put_seek_table\n");
-
- if (fas_get_frame_count(context) < 0)
- fail("n_frames = -1\n");
-
- if (fas_get_frame_count(context) < TEST_SET_SIZE)
- do_random_test(context, 0, fas_get_frame_count(context) - 1, N_ITERATIONS);
- else if (fas_get_frame_count(context) < TEST_SET_SIZE * 2)
- {
- do_random_test(context, 0, fas_get_frame_count(context) / 2 - 1, N_ITERATIONS / 2);
- do_random_test(context, fas_get_frame_count(context) / 2 + 1, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);
- }
- else
- {
- do_random_test(context, 0, TEST_SET_SIZE, N_ITERATIONS / 2);
- do_random_test(context, fas_get_frame_count(context) - TEST_SET_SIZE, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);
- }
-
- seek_release_table(&table);
- fas_close_video(context);
-
- success();
-}
-
diff --git a/ffmpeg-fas/test/generate_seek_table.c b/ffmpeg-fas/test/generate_seek_table.c
deleted file mode 100644
index 5549f57..0000000
--- a/ffmpeg-fas/test/generate_seek_table.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include "libavcodec/avcodec.h"
-#include "libavformat/avformat.h"
-#include <stdio.h>
-#include <string.h>
-#include "seek_indices.h"
-
-/* This executable is used for creating experimental seek tables.
- The show_seek_table executable will show the seek-table as ffmpeg_fas
- currently creates them.
- */
-
-int main (int argc, char **argv)
-{
- av_log_level = AV_LOG_QUIET;
-
- if (argc < 2) {
- fprintf (stderr, "usage: %s <video_file>\n", argv[0]);
- return -1;
- }
-
- av_register_all();
-
- AVFormatContext *pFormatCtx;
- if (av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL) !=0)
- return -1;
-
- if (av_find_stream_info(pFormatCtx)<0)
- return -1;
-
- unsigned int stream_id = -1;
- unsigned int i;
-
- for (i = 0; i < pFormatCtx->nb_streams; i++)
- if (pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
- {
- stream_id = i;
- break;
- }
-
- if (stream_id == -1)
- return -1;
-
- AVCodecContext *pCodecCtx = pFormatCtx->streams[stream_id]->codec;
- AVCodec *pCodec;
- pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
- if (pCodec==NULL)
- return -1;
-
- if (avcodec_open(pCodecCtx, pCodec)<0)
- return -1;
-
-
- // printf("\n%s \n",argv[1]);
-
- AVPacket Packet;
- int count = 0;
- int key_packets = 0;
- int non_key_packets = 0;
-
- int frame_count = 0;
- int key_frames = 0;
- int non_key_frames = 0;
-
- AVFrame *pFrame;
- pFrame=avcodec_alloc_frame();
- int frameFinished;
-
- seek_table_type table;
- table = seek_init_table (16);
- seek_entry_type entry;
-
- int64_t key_packet_dts;
- int64_t prev_packet_dts = AV_NOPTS_VALUE;
- int64_t first_packet_dts; /* ensure first keyframe gets first packet */
-
- int is_first_packet = 1;
- int frames_have_label = 1;
-
- // const char *format_name = pFormatCtx->iformat->name;
- // const char *codec_name = pFormatCtx->streams[stream_id]->codec->codec->name;
-
-
- /* these avi formats do not have labeled keyframes (the packets are labeled only and the packets and keyframe align 1-to-1 */
- /* DISABLING THIS TYPE OF GENERATION (these videos will be unseekable) */
- // fprintf(stderr, "format: (%s) codec: (%s)\n", format_name, codec_name);
-/*
- * if (!strcmp(format_name, "avi"))
- * if (!strcmp(codec_name, "aasc") ||
- * !strcmp(codec_name, "camtasia") ||
- * !strcmp(codec_name, "cinepak") ||
- * !strcmp(codec_name, "cyuv") ||
- * !strcmp(codec_name, "huffyuv") ||
- * !strcmp(codec_name, "indeo2") ||
- * !strcmp(codec_name, "indeo3") ||
- * !strcmp(codec_name, "msrle") ||
- * !strcmp(codec_name, "msvideo1") ||
- * !strcmp(codec_name, "mszh") ||
- * !strcmp(codec_name, "qpeg") ||
- * !strcmp(codec_name, "truemotion1") ||
- * !strcmp(codec_name, "ultimotion") ||
- * !strcmp(codec_name, "vp3") ||
- * !strcmp(codec_name, "zlib"))
- * frames_have_label = 0;
- */
-
- while (av_read_frame(pFormatCtx, &Packet) >= 0)
- {
- if (Packet.stream_index == stream_id)
- {
- // fprintf(stderr, "Packet: (P%d: %lld %lld %d)\n", count, Packet.pts, Packet.dts, Packet.flags);
- if ((Packet.flags & PKT_FLAG_KEY) || is_first_packet )
- {
- /* when keyframes overlap in the stream, that means multiple packets labeled 'keyframe' will arrive before
- the keyframe itself. this results in wrong assignments all around, but only the first one needs to be right.
- for all the rest, the seek-code will rewind to the previous keyframe to get them right.
- */
- if (is_first_packet)
- {
- first_packet_dts = Packet.dts;
- is_first_packet = 0;
- }
-
- // fprintf(stderr, "Packet: (P%d: %lld %lld)\n", count, Packet.pts, Packet.dts);
-
- /* first keyframe gets own dts, others get previous packet's dts.. this is workaround for some mpegs */
- /* sometimes you need the previous packet from the supposed keyframe packet to get a frame back that is */
- /* actually a keyframe */
-
- if (prev_packet_dts == AV_NOPTS_VALUE)
- key_packet_dts = Packet.dts;
- else
- key_packet_dts = prev_packet_dts;
-
- if (Packet.flags & PKT_FLAG_KEY)
- key_packets++;
- else
- non_key_packets++;
- }
- else
- non_key_packets++;
-
-
- avcodec_decode_video(pCodecCtx, pFrame, &frameFinished, Packet.data, Packet.size);
-
- if (frameFinished)
- {
-
- // fprintf(stderr, "Frame : (P%d F%d: %lld %lld L:%d)\n", count, frame_count, Packet.pts, Packet.dts, pFrame->key_frame);
- if ((pFrame->key_frame && frames_have_label) || ((Packet.flags & PKT_FLAG_KEY) && !frames_have_label))
- {
- key_frames++;
-
- entry.display_index = frame_count;
- entry.first_packet_dts = key_packet_dts;
- entry.last_packet_dts = Packet.dts;
-
- /* ensure first keyframe gets first packet dts */
- if (frame_count == 0)
- entry.first_packet_dts = first_packet_dts;
-
- seek_append_table_entry(&table, entry);
-
- // fprintf(stderr, "Frame : (P%d F%d: %lld %lld)\n", count, frame_count, Packet.pts, Packet.dts);
- }
- else
- non_key_frames++;
- frame_count++;
- }
-
- count++;
- prev_packet_dts = Packet.dts;
- }
-
- av_free_packet(&Packet);
- }
-
- // printf("\n");
-
- fprintf (stderr, "Packets: key: %d nonkey: %d total: %d\n", key_packets, non_key_packets, count);
- fprintf (stderr, "Frames : key: %d nonkey: %d total: %d\n", key_frames, non_key_frames, frame_count);
-
- table.completed = seek_true;
- table.num_frames = frame_count;
-
- seek_show_raw_table(stdout, table);
-
- return 1;
-}
diff --git a/ffmpeg-fas/test/movie_info.c b/ffmpeg-fas/test/movie_info.c
deleted file mode 100644
index f7bf40e..0000000
--- a/ffmpeg-fas/test/movie_info.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-
-#include <stdio.h>
-
-int main(int argc, char *argv[]) {
- AVFormatContext *pFormatCtx;
- int i, videoStream;
- AVCodecContext *pCodecCtx;
- AVCodec *pCodec;
- AVFrame *pFrame;
- AVFrame *pFrameRGB;
- AVPacket packet;
- int frameFinished;
- int numBytes;
- uint8_t *buffer;
-
- if(argc < 2) {
- printf("Please provide a movie file\n");
- return -1;
- }
- // Register all formats and codecs
- av_register_all();
-
- // Open video file
- if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
- return -1; // Couldn't open file
-
- // Retrieve stream information
- if(av_find_stream_info(pFormatCtx)<0)
- return -1; // Couldn't find stream information
-
- // Dump information about file onto standard error
- dump_format(pFormatCtx, 0, argv[1], 0);
-
- // Find the first video stream
- videoStream=-1;
- for(i=0; i<pFormatCtx->nb_streams; i++)
- if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
- videoStream=i;
- break;
- }
- if(videoStream==-1)
- return -1; // Didn't find a video stream
-
- // Get a pointer to the codec context for the video stream
- pCodecCtx=pFormatCtx->streams[videoStream]->codec;
-
- // Find the decoder for the video stream
- pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
- if(pCodec==NULL) {
- fprintf(stderr, "Unsupported codec!\n");
- return -1; // Codec not found
- }
- // Open codec
- if(avcodec_open(pCodecCtx, pCodec)<0)
- return -1; // Could not open codec
-
- return 0;
-}
diff --git a/ffmpeg-fas/test/run_test.py b/ffmpeg-fas/test/run_test.py
deleted file mode 100755
index 38dbb21..0000000
--- a/ffmpeg-fas/test/run_test.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import os
-
-def readFilelist(filename):
- try:
- f = open(filename, 'r')
- except:
- return []
- return [ele[:-1] for ele in f.readlines()]
-
-def create_filter_func(cmd, log_file):
- if log_file == "":
- return lambda filename : 0 == os.system(cmd + " " + filename)
- else:
- return lambda filename : 0 == os.system(cmd + " " + filename + " 2>> " + log_file)
-
-def write_filelist(files, filename):
- f = open(filename, 'w')
- for arg in files:
- f.write(arg + '\n')
- f.close()
-
-if __name__ == "__main__":
- if len(sys.argv) < 3 or len(sys.argv) > 4:
- print "Usage: " + sys.argv[0] + " <test_executable> <file_list>"
- raise SystemExit
-
-
- if not os.path.isfile(sys.argv[1]):
- print sys.argv[1] + " not found"
- raise SystemExit
-
- cmd = sys.argv[1]
- base_name = cmd.split('/')[-1]
-
- success_file = base_name + ".pass"
- fail_file = base_name + ".fail"
-
- if len(sys.argv) == 4:
- log_file = sys.argv[3]
- if os.path.isfile(log_file):
- os.system("rm " + log_file)
- else:
- log_file = ""
-
- files = readFilelist(sys.argv[2])
-
- filterfunc = create_filter_func(cmd, log_file)
- successful = filter(filterfunc, files)
- failed = list(set(files) - set(successful))
-
- write_filelist(failed, fail_file)
- write_filelist(successful, success_file)
-
diff --git a/ffmpeg-fas/test/seek_test.c b/ffmpeg-fas/test/seek_test.c
deleted file mode 100644
index 77f045e..0000000
--- a/ffmpeg-fas/test/seek_test.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include "ffmpeg_fas.h"
-#include "seek_indices.h"
-#include "test_support.h"
-#include <stdio.h>
-
-#define TEST_SET_SIZE 1000
-#define N_ITERATIONS 500
-
-int compare_frames(fas_raw_image_type img1, fas_raw_image_type img2)
-{
- // printf("(%d %d) (%d %d) (%d %d) (%d %d)\n", img1.width, img2.width,
- // img1.height, img2.height,
- // img1.bytes_per_line, img2.bytes_per_line,
- // img1.color_space, img2.color_space);
-
- if ((img1.width != img2.width) ||
- (img1.height != img2.height) ||
- (img1.bytes_per_line != img2.bytes_per_line) ||
- (img1.color_space != img2.color_space))
- return 0;
-
- int i,j;
- int mask = 0;
-
- for (i=0;i<img1.height;i++)
- for(j=0;j<img1.bytes_per_line;j++)
- {
- //printf("%d ", (img1.data[i*img1.bytes_per_line+j] - img2.data[i*img1.bytes_per_line+j+j]));
- mask |= (img1.data[i*img1.bytes_per_line+j] - img2.data[i*img1.bytes_per_line+j]);
- }
-
- if (mask == 0)
- return 1;
- else
- return 0;
-}
-
-void do_random_test(fas_context_ref_type context, int start, int stop, int count)
-{
- // printf ("start: %d stop: %d\n", start, stop );
-
- while (fas_get_frame_index(context) < start)
- if (FAS_SUCCESS != fas_step_forward(context))
- fail("failed on advancement\n");
-
- fas_raw_image_type *ref_frames = malloc( (stop - start + 1)* sizeof(fas_raw_image_type));
-
- int i;
- fas_error_type video_error;
-
- while (fas_get_frame_index(context) <= stop)
- {
- i = fas_get_frame_index(context) - start;
-
- video_error = fas_get_frame(context, &(ref_frames[i]));
- if (video_error != FAS_SUCCESS) fail("fail on test(1)\n");
-
- video_error = fas_step_forward(context);
- if (video_error != FAS_SUCCESS) fail("fail on test(2)\n");
-
- }
-
- int index = -1;
- int prev_index;
-
- for (i=0;i<count;i++)
- {
- int offset = random() % (stop - start + 1);
- prev_index = index;
- index = start + offset;
-
- video_error = fas_seek_to_frame(context, index);
- if (video_error != FAS_SUCCESS) fail("fail on test(seek)\n");
-
-
- fas_raw_image_type test_frame;
- video_error = fas_get_frame(context, &test_frame);
- if (video_error != FAS_SUCCESS) fail("fail on test(seek2)\n");
-
- // printf("offset: %d / %d\n", offset, stop - start + 1);
-
- if (!compare_frames(test_frame, ref_frames[offset]))
- {
- char buffer[70];
-
- sprintf(buffer, "fail-%d-test.ppm", index);
- ppm_save(&test_frame, buffer);
- sprintf(buffer, "fail-%d-ref.ppm", index);
- ppm_save(&ref_frames[offset], buffer);
- sprintf(buffer, "failed on compare after seeking (%d->%d)\n", prev_index, index);
-
- fail(buffer);
- }
-
- fas_free_frame(test_frame);
- }
-
- for (i=0;i<stop - start + 1;i++)
- free(ref_frames[i].data);
-
- free(ref_frames);
-}
-
-int main (int argc, char **argv)
-{
- fas_error_type video_error;
- fas_context_ref_type context;
-
- if (argc < 2) {
- fprintf (stderr, "usage: %s <video_file>\n", argv[0]);
- fail("arguments\n");
- }
-
- fprintf(stderr, "%s : ", argv[1]);
-
- fas_initialize (FAS_FALSE);
-
- video_error = fas_open_video (&context, argv[1]);
- if (video_error != FAS_SUCCESS) fail("fail on open\n");
-
- if (fas_get_frame_count(context) < 0)
- fail("failed on counting frames (completing seek table... bad table?)\n");
-
- if (fas_get_frame_count(context) < TEST_SET_SIZE)
- do_random_test(context, 0, fas_get_frame_count(context) - 1, N_ITERATIONS);
- else if (fas_get_frame_count(context) < TEST_SET_SIZE * 2)
- {
- do_random_test(context, 0, fas_get_frame_count(context) / 2 - 1, N_ITERATIONS / 2);
- do_random_test(context, fas_get_frame_count(context) / 2 + 1, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);
- }
- else
- {
- do_random_test(context, 0, TEST_SET_SIZE, N_ITERATIONS / 2);
- do_random_test(context, fas_get_frame_count(context) - TEST_SET_SIZE, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);
- }
-
- fas_close_video(context);
-
- success();
-}
-
diff --git a/ffmpeg-fas/test/show_seek_table.c b/ffmpeg-fas/test/show_seek_table.c
deleted file mode 100644
index 6974bc2..0000000
--- a/ffmpeg-fas/test/show_seek_table.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#include "seek_indices.h"
-#include "ffmpeg_fas.h"
-#include <stdio.h>
-
-int main (int argc, char **argv)
-{
- fas_error_type video_error;
- fas_context_ref_type context;
- fas_raw_image_type image_buffer;
-
- if (argc < 2) {
- fprintf (stderr, "usage: %s <video_file>\n", argv[0]);
- return -1;
- }
-
- fas_initialize (FAS_FALSE);
-
- video_error = fas_open_video (&context, argv[1]);
- if (video_error != FAS_SUCCESS)
- return -1;
-
- while (fas_frame_available (context))
- {
- if (FAS_SUCCESS != fas_get_frame (context, &image_buffer))
- return -1;
- fas_free_frame (image_buffer);
-
- video_error = fas_step_forward (context);
- }
-
- seek_table_type table;
- table = fas_get_seek_table(context);
-
- seek_show_raw_table(stdout, table);
-
- return 1;
-}
-
diff --git a/ffmpeg-fas/test/test_support.h b/ffmpeg-fas/test/test_support.h
deleted file mode 100644
index 5b91a1a..0000000
--- a/ffmpeg-fas/test/test_support.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
- * Copyright 2008. Pittsburgh Pattern Recognition, Inc.
- *
- * This file is part of the Frame Accurate Seeking extension library to
- * ffmpeg (ffmpeg-fas).
- *
- * ffmpeg-fas is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * The ffmpeg-fas library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the ffmpeg-fas library. If not, see <http://www.gnu.org/licenses/>.
- *
- ******************************************************************************/
-
-#ifndef FAS_TEST_SUPPORT
-#define FAS_TEST_SUPPORT
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define fail(x) { fprintf(stderr, "fail : "); fprintf(stderr, x); exit(EXIT_FAILURE); }
-#define success() { fprintf(stderr, "success\n"); exit(EXIT_SUCCESS); }
-
-/*
- * static void pgm_save(ppt_raw_image_type *image, char *filename)
- * {
- * FILE *f;
- * int i;
- *
- * f=fopen(filename,"w");
- * fprintf(f,"P5\n%d\n%d\n%d\n", image->width, image->height, 255);
- *
- * for(i=0; i<image->height; i++) {
- * fwrite(image->data + i * image->bytes_per_line, 1, image->width, f);
- * }
- *
- * fclose(f);
- * }
- */
-
-static void ppm_save(fas_raw_image_type *image, char *filename)
-{
- FILE *f;
- int i;
-
- if (image->color_space != FAS_RGB24) {
- return;
- }
-
- f=fopen(filename,"wb");
- fprintf(f,"P6\n%d %d\n%d\n", image->width, image->height, 255);
-
- for(i=0; i<image->height; i++) {
- fwrite(image->data + i * image->bytes_per_line, 1, image->width * 3, f);
- }
-
- fclose(f);
-}
-
-#endif
diff --git a/libavwrapper/Makefile b/libavwrapper/Makefile
deleted file mode 100644
index ded20b6..0000000
--- a/libavwrapper/Makefile
+++ /dev/null
@@ -1,251 +0,0 @@
-# The pre-processor and compiler options.
-
-#http://docs.gstreamer.com/display/GstSDK/Installing+on+Linux
-
-#MY_CFLAGS = -fpermissive -std=c++11 -Wno-error -I /opt/gstreamer-sdk/include/gstreamer-0.10/ -I /opt/gstreamer-sdk/include/glib-2.0 -I /opt/gstreamer-sdk/lib/glib-2.0/include -I /opt/gstreamer-sdk/include/libxml2 $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-#MY_CFLAGS = -fpermissive -std=c++11 -Wno-error $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-
-# -I ../ffmpeg
-
-# The linker options.libgstaasinklibgstaasink.so
-MY_LIBS = -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil
-#MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --libs)
-# -lgstreamer-0.10 -lgstreamer-video-0.10 -lgstreamer-base-0.10 -lglib-2.0 -lgstapp-0.10
-#MY_LIBS = ../libavcodec/ffmpeg/libavcodec/libavcodec.a ../libavcodec/ffmpeg/libavutil/libavutil.a ../libavcodec/ffmpeg/libavformat/libavformat.a ../libavcodec/ffmpeg/libavfilter/libavfilter.a ../libavcodec/ffmpeg/libavdevice/libavdevice.a -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk
-#GAH! HARD!
-
-# The pre-processor options used by the cpp (man cpp for more).
-CPPFLAGS = -Wall
-
-# The options used in linking as well as in any direct use of ld.
-LDFLAGS =
-
-# The directories in which source files reside.
-# If not specified, only the current directory will be serached.
-SRCDIRS =
-
-# The executable file name.
-# If not specified, current directory name or `a.out' will be used.
-PROGRAM =
-
-## Implicit Section: change the following only when necessary.
-##==========================================================================
-
-# The source file types (headers excluded).
-# .c indicates C source files, and others C++ ones.
-SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
-
-# The header file types.
-HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
-
-# The pre-processor and compiler options.
-# Users can override those variables from the command line.
-CFLAGS = -g -O2
-CXXFLAGS=
-
-# The C program compiler.
-#CC = gcc
-
-# The C++ program compiler.
-#CXX = g++
-
-# Un-comment the following line to compile C programs as C++ ones.
-#CC = $(CXX)
-
-# The command used to delete file.
-RM = rm -f
-
-ETAGS = etags
-ETAGSFLAGS =
-
-CTAGS = ctags
-CTAGSFLAGS =
-
-## Stable Section: usually no need to be changed. But you can add more.
-##==========================================================================
-SHELL = /bin/sh
-EMPTY =
-SPACE = $(EMPTY) $(EMPTY)
-ifeq ($(PROGRAM),)
- CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
- PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
- ifeq ($(PROGRAM),)
- PROGRAM = a.out
- endif
-endif
-ifeq ($(SRCDIRS),)
- SRCDIRS = .
-endif
-SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
-HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
-SRC_CXX = $(filter-out %.c,$(SOURCES))
-OBJS = $(addsuffix .o, $(basename $(SOURCES)))
-DEPS = $(OBJS:.o=.d)
-
-## Define some useful variables.
-DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
- echo "-MM -MP"; else echo "-M"; fi )
-DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
-DEPEND.d = $(subst -g ,,$(DEPEND))
-COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c
-COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
-LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-.PHONY: all objs tags ctags clean distclean help show install
-
-# Delete the default suffixes
-.SUFFIXES:
-
-all: Release
-
-Clang: CXX = clang
-
-Clang: $(PROGRAM)
-
-Release: CXXFLAGS += -O2
-
-Release: $(PROGRAM)
-
-Debug: CXXFLAGS += -g3
-
-Debug: $(PROGRAM)
-
-prefix=/usr/local
-
-Install: rotord
- strip rotord
- install -m 0755 rotord $(prefix)/bin
-
-
-# Rules for creating dependency files (.d).
-#------------------------------------------
-
-%.d:%.c
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.C
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cc
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cpp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.CPP
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.c++
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cxx
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-# Rules for generating object files (.o).
-#----------------------------------------
-objs:$(OBJS)
-
-%.o:%.c
- $(COMPILE.c) $< -o $@
-
-%.o:%.C
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cc
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cpp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.CPP
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.c++
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cxx
- $(COMPILE.cxx) $< -o $@
-
-# Rules for generating the tags.
-#-------------------------------------
-tags: $(HEADERS) $(SOURCES)
- $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
-
-ctags: $(HEADERS) $(SOURCES)
- $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
-
-# Rules for generating the executable.
-#-------------------------------------
-$(PROGRAM):$(OBJS)
-ifeq ($(SRC_CXX),) # C program
- $(LINK.c) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-else # C++ program
- $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-endif
-
-ifndef NODEP
-ifneq ($(DEPS),)
- sinclude $(DEPS)
-endif
-endif
-
-
-clean:
- $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
-
-distclean: clean
- $(RM) $(DEPS) TAGS
-
-# Show help.
-help:
- @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
- @echo 'Copyright (C) 2007, 2008 whyglinux <whyglinux@hotmail.com>'
- @echo
- @echo 'Usage: make [TARGET]'
- @echo 'TARGETS:'
- @echo ' all (=make) compile and link.'
- @echo ' NODEP=yes make without generating dependencies.'
- @echo ' objs compile only (no linking).'
- @echo ' tags create tags for Emacs editor.'
- @echo ' ctags create ctags for VI editor.'
- @echo ' clean clean objects and the executable file.'
- @echo ' distclean clean objects, the executable and dependencies.'
- @echo ' show show variables (for debug use only).'
- @echo ' help print this message.'
- @echo
- @echo 'Report bugs to <whyglinux AT gmail DOT com>.'
-
-# Show variables (for debug use only.)
-show:
- @echo 'PROGRAM :' $(PROGRAM)
- @echo 'SRCDIRS :' $(SRCDIRS)
- @echo 'HEADERS :' $(HEADERS)
- @echo 'SOURCES :' $(SOURCES)
- @echo 'SRC_CXX :' $(SRC_CXX)
- @echo 'OBJS :' $(OBJS)
- @echo 'DEPS :' $(DEPS)
- @echo 'DEPEND :' $(DEPEND)
- @echo 'COMPILE.c :' $(COMPILE.c)
- @echo 'COMPILE.cxx :' $(COMPILE.cxx)
- @echo 'link.c :' $(LINK.c)
- @echo 'link.cxx :' $(LINK.cxx)
-
-## End of the Makefile ## Suggestions are welcome ## All rights reserved ##
-#############################################################################
diff --git a/libavwrapper/libavwrapper.cpp b/libavwrapper/libavwrapper.cpp
deleted file mode 100755
index 5e1a50d..0000000
--- a/libavwrapper/libavwrapper.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
- #include "libavwrapper.h"
-
-
-extern "C"
-{
-#include <libswscale/swscale.h>
-}
-
-/*
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QEventLoop>
-#include <QFileInfo>
-#include <QMutexLocker>
-#include <QDebug>
-*/
-
-#include <stdexcept>
-#include <iostream>
-#include <cassert>
-
-using namespace std;
-
-// Translated to C++ by Christopher Bruns May 2012
-// from ffmeg_adapt.c in whisk package by Nathan Clack, Mark Bolstadt, Michael Meeuwisse
-
-//QMutex decoder::mutex;
-
-// Avoid link error on some macs
-#ifdef __APPLE__
-extern "C" {
-#include <stdlib.h>
-#include <errno.h>
-// #include "compiler/compiler.h"
-
-/*
- * Darwin doesn't have posix_memalign(), provide a private
- * weak alternative
- */
- /*
-int __weak posix_memalign(void **ptr, size_t align, size_t size)
-{
- if (*ptr)
- return 0;
-
- return ENOMEM;
-}
-*/
-}
-#endif
-
-// Custom read function so FFMPEG does not need to read from a local file by name.
-// But rather from a stream derived from a URL or whatever.
-extern "C" {
-
-int readFunction(void* opaque, uint8_t* buf, int buf_size)
-{
- //QIODevice* stream = (QIODevice*)opaque;
- ifstream* stream = (ifstream*)opaque;
- //int numBytes =
- stream->read((char*)buf, (streamsize)buf_size);
- return stream->gcount(); //?? is this right
- //numBytes; //TODO work out
-}
-
-// http://cdry.wordpress.com/2009/09/09/using-custom-io-callbacks-with-ffmpeg/
-int64_t seekFunction(void* opaque, int64_t offset, int whence)
-{
- //QIODevice* stream = (QIODevice*)opaque;
- ifstream* stream = (ifstream*)opaque;
- if (stream == NULL)
- return -1;
- else if (whence == AVSEEK_SIZE)
- return -1; // "size of my handle in bytes"
- //else if (stream->isSequential())
- // return -1; // cannot seek a sequential stream //presume this would be certain kind of network stream
- else if (whence == SEEK_CUR) { // relative to start of file
- if (! stream->seekg(offset,ios_base::cur)) //stream->pos() + offset) )
- return -1;
- }
- else if (whence == SEEK_END) { // relative to end of file
- assert(offset < 0);
- if (! stream->seekg(offset,ios_base::end)) //stream->size() + offset) )
- return -1;
- }
- else if (whence == SEEK_SET) { // relative to start of file
- if (! stream->seekg(offset) )
- return -1;
- }
- else {
- assert(false);
- }
- return stream->tellg();
-}
-
-}
-
-
-/////////////////////////////
-// AVPacketWrapper methods //
-/////////////////////////////
-
-
-class AVPacketWrapper
-{
-public:
- AVPacketWrapper();
- virtual ~AVPacketWrapper();
- void free();
-
- AVPacket packet;
-};
-
-
-AVPacketWrapper::AVPacketWrapper()
-{
- packet.destruct = NULL;
-}
-
-/* virtual */
-AVPacketWrapper::~AVPacketWrapper()
-{
- free();
-}
-
-void AVPacketWrapper::free()
-{
- av_free_packet(&packet);
-}
-
-
-/////////////////////////
-// decoder methods //
-/////////////////////////
-
-libav::decoder::decoder(PixelFormat pixelFormat)
- : isOpen(false)
-{
- initialize();
- format = pixelFormat;
-}
-
-/*
-decoder::decoder(QUrl url, PixelFormat pixelFormat)
- : isOpen(false)
-{
- //QMutexLocker lock(&decoder::mutex);
- initialize();
- format = pixelFormat;
- isOpen = open(url, pixelFormat);
-}
-*/
-
-/* virtual */
-libav::decoder::~decoder()
-{
- //QMutexLocker lock(&decoder::mutex);
- if (NULL != Sctx) {
- sws_freeContext(Sctx);
- Sctx = NULL;
- }
- if (NULL != pRaw) {
- av_free(pRaw);
- pRaw = NULL;
- }
- if (NULL != pFrameRGB) {
- av_free(pFrameRGB);
- pFrameRGB = NULL;
- }
- if (NULL != pCtx) {
- avcodec_close(pCtx);
- pCtx = NULL;
- }
- if (NULL != container) {
- avformat_close_input(&container);
- container = NULL;
- }
- if (NULL != buffer) {
- av_free(buffer);
- buffer = NULL;
- }
- if (NULL != blank) {
- av_free(blank);
- blank = NULL;
- }
- /*
- if (NULL != avioContext) {
- av_free(avioContext);
- avioContext = NULL;
- }
- */
- //QNetworkreply
- //if (reply != NULL) {
- // reply->deleteLater();
- // reply = NULL;
- //}
- // Don't need to free pCodec?
-}
-/*
-bool decoder::open(QUrl url, enum PixelFormat formatParam)
-{
- if (url.isEmpty())
- return false;
-
- // Is the movie source a local file?
- if (url.host() == "localhost")
- url.setHost("");
- QString fileName = url.toLocalFile();
- if ( (! fileName.isEmpty())
- && (QFileInfo(fileName).exists()) )
- {
- // return open(fileName, formatParam); // for testing only
-
- // Yes, the source is a local file
- fileStream.setFileName(fileName);
- // qDebug() << fileName;
- if (! fileStream.open(QIODevice::ReadOnly))
- return false;
- return open(fileStream, fileName, formatParam);
- }
-
- // ...No, the source is not a local file
- if (url.host() == "")
- url.setHost("localhost");
- fileName = url.path();
-
- // http://stackoverflow.com/questions/9604633/reading-a-file-located-in-memory-with-libavformat
- // Load from URL
- QEventLoop loop; // for synchronous url fetch http://stackoverflow.com/questions/5486090/qnetworkreply-wait-for-finished
- QObject::connect(&networkManager, SIGNAL(finished(QNetworkReply*)),
- &loop, SLOT(quit()));
- QNetworkRequest request = QNetworkRequest(url);
- // qDebug() << "networkManager" << __FILE__ << __LINE__;
- reply = networkManager.get(request);
- loop.exec();
- if (reply->error() != QNetworkReply::NoError) {
- // qDebug() << reply->error();
- reply->deleteLater();
- reply = NULL;
- return false;
- }
- QIODevice * stream = reply;
- // Mpeg needs seekable device, so create in-memory buffer if necessary
- if (stream->isSequential()) {
- byteArray = stream->readAll();
- fileBuffer.setBuffer(&byteArray);
- fileBuffer.open(QIODevice::ReadOnly);
- if (! fileBuffer.seek(0))
- return false;
- stream = &fileBuffer;
- assert(! stream->isSequential());
- }
- bool result = open(*stream, fileName, formatParam);
- return result;
-}
-
-bool decoder::open(QIODevice& fileStream, QString& fileName, enum PixelFormat formatParam)
-{
- // http://stackoverflow.com/questions/9604633/reading-a-file-located-in-memory-with-libavformat
- // I think AVIOContext is the trick used to redivert the input stream
- ioBuffer = (unsigned char *)av_malloc(ioBufferSize + FF_INPUT_BUFFER_PADDING_SIZE); // can get av_free()ed by libav
- avioContext = avio_alloc_context(ioBuffer, ioBufferSize, 0, (void*)(&fileStream), &readFunction, NULL, &seekFunction);
- container = avformat_alloc_context();
- container->pb = avioContext;
-
- // Open file, check usability
- std::string fileNameStd = fileName.toStdString();
- if (!avtry( avformat_open_input(&container, fileNameStd.c_str(), NULL, NULL), fileNameStd ))
- return false;
- return openUsingInitializedContainer(formatParam);
-}
-*/
-// file name based method for historical continuity
-bool libav::decoder::open(char* fileName, enum PixelFormat formatParam){
-
- if (!avtry( avformat_open_input(&container, fileName, NULL, NULL), string(fileName) ))
- return false;
- return openUsingInitializedContainer(formatParam);
-}
-bool libav::decoder::open(string& fileName, enum PixelFormat formatParam)
-{
- // Open file, check usability
-
- if (!avtry( avformat_open_input(&container, fileName.c_str(), NULL, NULL), fileName ))
- return false;
- return openUsingInitializedContainer(formatParam);
-}
-
-
-bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
-{
- format = formatParam;
- sc = getNumberOfChannels();
-
- if (!avtry( avformat_find_stream_info(container, NULL), "Cannot find stream information." ))
- return false;
- if (!avtry( videoStream=av_find_best_stream(container, AVMEDIA_TYPE_VIDEO, -1, -1, &pCodec, 0), "Cannot find a video stream." ))
- return false;
- pCtx=container->streams[videoStream]->codec;
- width = pCtx->width;
- height = pCtx->height;
- if (!avtry( avcodec_open2(pCtx, pCodec, NULL), "Cannot open video decoder." ))
- return false;
-
- /* Frame rate fix for some codecs */
- if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 )
- pCtx->time_base.den = 1000;
-
- /* Compute the total number of frames in the file */
- /* duration is in microsecs */
- numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5);
-
- /* Get framebuffers */
- if (! (pRaw = avcodec_alloc_frame()) )
- throw std::runtime_error("");
- if (! (pFrameRGB = avcodec_alloc_frame()) )
- throw std::runtime_error("");
-
- /* Create data buffer */
- if (format == PIX_FMT_NONE) {
- numBytes = 0;
- buffer = NULL;
- blank = NULL;
- pFrameRGB = NULL;
- Sctx = NULL;
- }
- else {
- numBytes = avpicture_get_size( format, pCtx->width, pCtx->height ); // RGB24 format
- if (! (buffer = (uint8_t*)av_malloc(numBytes + FF_INPUT_BUFFER_PADDING_SIZE)) ) // RGB24 format
- throw std::runtime_error("");
- if (! (blank = (uint8_t*)av_mallocz(avpicture_get_size(pCtx->pix_fmt,width,height))) ) // native codec format
- throw std::runtime_error("");
-
- /* Init buffers */
- avpicture_fill( (AVPicture * ) pFrameRGB, buffer, format,
- pCtx->width, pCtx->height );
-
- /* Init scale & convert */
- if (! (Sctx=sws_getContext(
- pCtx->width,
- pCtx->height,
- pCtx->pix_fmt,
- width,
- height,
- format,
- SWS_POINT, // fastest?
- NULL,NULL,NULL)) )
- throw std::runtime_error("");
- }
-
- /* Give some info on stderr about the file & stream */
- //dump_format(container, 0, fname, 0);
-
- previousFrameIndex = -1;
- return true;
-}
-
-bool libav::decoder::fetchFrame(int targetFrameIndex)
-{
- if ((targetFrameIndex < 0) || (targetFrameIndex > numFrames))
- return false;
- if (targetFrameIndex == (previousFrameIndex + 1)) {
- if (! readNextFrame(targetFrameIndex))
- return false;
- }
- else
- if (seekToFrame(targetFrameIndex) < 0)
- return false;
- previousFrameIndex = targetFrameIndex;
- return true;
-}
-
-// \returns current frame on success, otherwise -1
-int libav::decoder::seekToFrame(int targetFrameIndex)
-{
- int64_t duration = container->streams[videoStream]->duration;
- int64_t ts = av_rescale(duration,targetFrameIndex,numFrames);
- int64_t tol = av_rescale(duration,1,2*numFrames);
- if ( (targetFrameIndex < 0) || (targetFrameIndex >= numFrames) ) {
- return -1;
- }
- int result = avformat_seek_file( container, //format context
- videoStream,//stream id
- 0, //min timestamp
- ts, //target timestamp
- ts, //max timestamp
- 0); //AVSEEK_FLAG_ANY),//flags
- if (result < 0)
- return -1;
-
- avcodec_flush_buffers(pCtx);
- if (! readNextFrame(targetFrameIndex))
- return -1;
-
- return targetFrameIndex;
-}
-
-bool libav::decoder::readNextFrame(int targetFrameIndex)
-{
- AVPacket packet = {0};
- av_init_packet(&packet);
- bool result = readNextFrameWithPacket(targetFrameIndex, packet, pRaw);
- av_free_packet(&packet);
- return result;
-}
-
-// WARNING this method can raise an exception
-bool libav::decoder::readNextFrameWithPacket(int targetFrameIndex, AVPacket& packet, AVFrame* pYuv)
-{
- int finished = 0;
- do {
- finished = 0;
- av_free_packet(&packet);
- int result;
- if (!avtry(av_read_frame( container, &packet ), "Failed to read frame"))
- return false; // !!NOTE: see docs on packet.convergence_duration for proper seeking
- if( packet.stream_index != videoStream ) /* Is it what we're trying to parse? */
- continue;
- if (!avtry(avcodec_decode_video2( pCtx, pYuv, &finished, &packet ), "Failed to decode video"))
- return false;
- // handle odd cases and debug
- if((pCtx->codec_id==CODEC_ID_RAWVIDEO) && !finished)
- {
- avpicture_fill( (AVPicture * ) pYuv, blank, pCtx->pix_fmt,width, height ); // set to blank frame
- finished = 1;
- }
-#if 0 // very useful for debugging
- cout << "Packet - pts:" << (int)packet.pts;
- cout << " dts:" << (int)packet.dts;
- cout << " - flag: " << packet.flags;
- cout << " - finished: " << finished;
- cout << " - Frame pts:" << (int)pYuv->pts;
- cout << " " << (int)pYuv->best_effort_timestamp;
- cout << endl;
- /* printf("Packet - pts:%5d dts:%5d (%5d) - flag: %1d - finished: %3d - Frame pts:%5d %5d\n",
- (int)packet.pts,(int)packet.dts,
- packet.flags,finished,
- (int)pYuv->pts,(int)pYuv->best_effort_timestamp); */
-#endif
- if(!finished) {
- if (packet.pts == AV_NOPTS_VALUE)
- throw std::runtime_error("");
- if (packet.size == 0) // packet.size==0 usually means EOF
- break;
- }
- } while ( (!finished) || (pYuv->best_effort_timestamp < targetFrameIndex));
-
- av_free_packet(&packet);
-
- if (format != PIX_FMT_NONE) {
- sws_scale(Sctx, // sws context
- pYuv->data, // src slice
- pYuv->linesize, // src stride
- 0, // src slice origin y
- pCtx->height, // src slice height
- pFrameRGB->data, // dst
- pFrameRGB->linesize ); // dst stride
- }
-
- previousFrameIndex = targetFrameIndex;
- return true;
-}
-
-uint8_t libav::decoder::getPixelIntensity(int x, int y, Channel c) const
-{
- return *(pFrameRGB->data[0] + y * pFrameRGB->linesize[0] + x * sc + c);
-}
-
-int libav::decoder::getNumberOfFrames() const { return numFrames; }
-
-int libav::decoder::getWidth() const { return width; }
-
-int libav::decoder::getHeight() const { return height; }
-
-int libav::decoder::getNumberOfChannels() const
-{
- switch(format)
- {
- case PIX_FMT_BGRA:
- return 4;
- break;
- case PIX_FMT_RGB24:
- return 3;
- break;
- case PIX_FMT_GRAY8:
- return 1;
- break;
- default:
- return 0;
- break;
- }
- return 0;
-}
-
-void libav::decoder::initialize()
-{
- Sctx = NULL;
- pRaw = NULL;
- pFrameRGB = NULL;
- pCtx = NULL;
- container = NULL;
- buffer = NULL;
- blank = NULL;
- pCodec = NULL;
- format = PIX_FMT_NONE;
- //network stuff
- //reply = NULL;
- //ioBuffer = NULL;
- //avioContext = NULL;
- decoder::maybeInitFFMpegLib();
-}
-
-void libav::decoder::maybeInitFFMpegLib()
-{
- if (decoder::b_is_one_time_inited)
- return;
- av_register_all();
- avcodec_register_all();
- avformat_network_init();
- decoder::b_is_one_time_inited = true;
-}
-
-bool libav::decoder::avtry(int result, const std::string& msg) {
- if ((result < 0) && (result != AVERROR_EOF)) {
- char buf[1024];
- av_strerror(result, buf, sizeof(buf));
- std::string message = std::string("libav::Error: ") + msg + buf;
- //qDebug() << QString(message.c_str());
- cerr<<message<<endl;
- return false;
- }
- return true;
-}
-
-bool libav::decoder::b_is_one_time_inited = false;
-
-
-
-///////////////////////////
-// encoder methods //
-///////////////////////////
-
-
-libav::encoder::encoder(const char * file_name, int width, int height, enum AVCodecID codec_id)
- : picture_yuv(NULL)
- , picture_rgb(NULL)
- , container(NULL)
-{
- if (0 != (width % 2))
- cerr << "WARNING: Video width is not a multiple of 2" << endl;
- if (0 != (height % 2))
- cerr << "WARNING: Video height is not a multiple of 2" << endl;
-
- decoder::maybeInitFFMpegLib();
-
- container = avformat_alloc_context();
- if (NULL == container)
- throw std::runtime_error("Unable to allocate format context");
-
- AVOutputFormat * fmt = av_guess_format(NULL, file_name, NULL);
- if (!fmt)
- fmt = av_guess_format("mpeg", NULL, NULL);
- if (!fmt)
- throw std::runtime_error("Unable to deduce video format");
- container->oformat = fmt;
-
- fmt->video_codec = codec_id;
- // fmt->video_codec = CODEC_ID_H264; // fails to write
-
- AVStream * video_st = avformat_new_stream(container, NULL);
-
- pCtx = video_st->codec;
- pCtx->codec_id = fmt->video_codec;
- pCtx->codec_type = AVMEDIA_TYPE_VIDEO;
- // resolution must be a multiple of two
- pCtx->width = width;
- pCtx->height = height;
-
- // bit_rate determines image quality
- pCtx->bit_rate = width * height * 4; // ?
- // pCtx->qmax = 50; // no effect?
-
- // "high quality" parameters from http://www.cs.ait.ac.th/~on/mplayer/pl/menc-feat-enc-libavcodec.html
- // vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:vme=5:naq:qns=2
- if (false) // does not help
- // if (pCtx->codec_id == CODEC_ID_MPEG4)
- {
- pCtx->mb_decision = 2;
- pCtx->last_predictor_count = 3;
- pCtx->pre_dia_size = 2;
- pCtx->dia_size = 2;
- pCtx->max_b_frames = 2;
- pCtx->b_frame_strategy = 2;
- pCtx->trellis = 2;
- pCtx->compression_level = 2;
- pCtx->global_quality = 300;
- pCtx->pre_me = 2;
- pCtx->mv0_threshold = 1;
- // pCtx->quantizer_noise_shaping = 2; // deprecated
- // TODO
- }
-
- pCtx->time_base = (AVRational){1, 25};
- // pCtx->time_base = (AVRational){1, 10};
- pCtx->gop_size = 12; // emit one intra frame every twelve frames
- // pCtx->max_b_frames = 0;
- pCtx->pix_fmt = PIX_FMT_YUV420P;
- if (fmt->flags & AVFMT_GLOBALHEADER)
- pCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
- if (pCtx->codec_id == CODEC_ID_H264)
- {
- // http://stackoverflow.com/questions/3553003/encoding-h-264-with-libavcodec-x264
- pCtx->coder_type = 1; // coder = 1
- pCtx->flags|=CODEC_FLAG_LOOP_FILTER; // flags=+loop
- pCtx->me_cmp|= 1; // cmp=+chroma, where CHROMA = 1
- // pCtx->partitions|=X264_PART_I8X8+X264_PART_I4X4+X264_PART_P8X8+X264_PART_B8X8; // partitions=+parti8x8+parti4x4+partp8x8+partb8x8
- pCtx->me_method=ME_HEX; // me_method=hex
- pCtx->me_subpel_quality = 7; // subq=7
- pCtx->me_range = 16; // me_range=16
- pCtx->gop_size = 250; // g=250
- pCtx->keyint_min = 25; // keyint_min=25
- pCtx->scenechange_threshold = 40; // sc_threshold=40
- pCtx->i_quant_factor = 0.71; // i_qfactor=0.71
- pCtx->b_frame_strategy = 1; // b_strategy=1
- pCtx->qcompress = 0.6; // qcomp=0.6
- pCtx->qmin = 10; // qmin=10
- pCtx->qmax = 51; // qmax=51
- pCtx->max_qdiff = 4; // qdiff=4
- pCtx->max_b_frames = 3; // bf=3
- pCtx->refs = 3; // refs=3
- // pCtx->directpred = 1; // directpred=1
- pCtx->trellis = 1; // trellis=1
- // pCtx->flags2|=CODEC_FLAG2_BPYRAMID+CODEC_FLAG2_MIXED_REFS+CODEC_FLAG2_WPRED+CODEC_FLAG2_8X8DCT+CODEC_FLAG2_FASTPSKIP; // flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
- // pCtx->weighted_p_pred = 2; // wpredp=2
- // libx264-main.ffpreset preset
- // pCtx->flags2|=CODEC_FLAG2_8X8DCT;
- // pCtx->flags2^=CODEC_FLAG2_8X8DCT; // flags2=-dct8x8
- }
-
- AVCodec * codec = avcodec_find_encoder(pCtx->codec_id);
- if (NULL == codec)
- throw std::runtime_error("Unable to find Mpeg4 codec");
- if (codec->pix_fmts)
- pCtx->pix_fmt = codec->pix_fmts[0];
- {
- //QMutexLocker lock(&decoder::mutex);
- if (avcodec_open2(pCtx, codec, NULL) < 0)
- throw std::runtime_error("Error opening codec");
- }
-
- /* Get framebuffers */
- if (! (picture_yuv = avcodec_alloc_frame()) ) // final frame format
- throw std::runtime_error("");
- if (! (picture_rgb = avcodec_alloc_frame()) ) // rgb version I can understand easily
- throw std::runtime_error("");
- /* the image can be allocated by any means and av_image_alloc() is
- * just the most convenient way if av_malloc() is to be used */
- if ( av_image_alloc(picture_yuv->data, picture_yuv->linesize,
- pCtx->width, pCtx->height, pCtx->pix_fmt, 1) < 0 )
- throw std::runtime_error("Error allocating YUV frame buffer");
- if ( av_image_alloc(picture_rgb->data, picture_rgb->linesize,
- pCtx->width, pCtx->height, PIX_FMT_RGB24, 1) < 0 )
- throw std::runtime_error("Error allocating RGB frame buffer");
-
- /* Init scale & convert */
- if (! (Sctx=sws_getContext(
- width,
- height,
- PIX_FMT_RGB24,
- pCtx->width,
- pCtx->height,
- pCtx->pix_fmt,
- SWS_BICUBIC,NULL,NULL,NULL)) )
- throw std::runtime_error("");
-
- /* open the output file */
- if (!(fmt->flags & AVFMT_NOFILE))
- {
- //QMutexLocker lock(&decoder::mutex);
- if (avio_open(&container->pb, file_name, AVIO_FLAG_WRITE) < 0)
- throw std::runtime_error("Error opening output video file");
- }
- avformat_write_header(container, NULL);
-}
-
-void libav::encoder::setPixelIntensity(int x, int y, int c, uint8_t value)
-{
- uint8_t * ptr = picture_rgb->data[0] + y * picture_rgb->linesize[0] + x * 3 + c;
- *ptr = value;
-}
-
-void libav::encoder::write_frame()
-{
- // convert from RGB24 to YUV
- sws_scale(Sctx, // sws context
- picture_rgb->data, // src slice
- picture_rgb->linesize, // src stride
- 0, // src slice origin y
- pCtx->height, // src slice height
- picture_yuv->data, // dst
- picture_yuv->linesize ); // dst stride
-
- /* encode the image */
- // use non-deprecated avcodec_encode_video2(...)
- AVPacket packet;
- av_init_packet(&packet);
- packet.data = NULL;
- packet.size = 0;
-
- int got_packet;
- int ret = avcodec_encode_video2(pCtx,
- &packet,
- picture_yuv,
- &got_packet);
- if (ret < 0)
- throw std::runtime_error("Video encoding failed");
- if (got_packet)
- {
- // std::cout << "encoding frame" << std::endl;
- int result = av_write_frame(container, &packet);
- av_destruct_packet(&packet);
- }
-}
-
-/* virtual */
-libav::encoder::~encoder()
-{
- int result = av_write_frame(container, NULL); // flush
- result = av_write_trailer(container);
- {
- //QMutexLocker lock(&decoder::mutex);
- avio_close(container->pb);
- }
- for (int i = 0; i < container->nb_streams; ++i)
- av_freep(container->streams[i]);
- av_free(container);
- container = NULL;
-
- {
- //QMutexLocker lock(&decoder::mutex);
- avcodec_close(pCtx);
- }
- av_free(pCtx);
- pCtx = NULL;
- av_free(picture_yuv->data[0]);
- av_free(picture_yuv);
- picture_yuv = NULL;
- av_free(picture_rgb->data[0]);
- av_free(picture_rgb);
- picture_rgb = NULL;
-}
-
-
-
diff --git a/libavwrapper/libavwrapper.h b/libavwrapper/libavwrapper.h
deleted file mode 100755
index 449c2f2..0000000
--- a/libavwrapper/libavwrapper.h
+++ /dev/null
@@ -1,150 +0,0 @@
- #ifndef libavwrapper_H
-#define libavwrapper_H
-
-/*
- * libavwrapper.h
- * May 2012 Christopher Bruns
- * The libavwrapper class is a C++ wrapper around the poorly documented
- * libavcodec movie API used by ffmpeg. I made extensive use of Nathan
- * Clack's implemention in the whisk project.
- *
- * The libavwrapper.h and libavwrapper.cpp files depend only on the libavcodec
- * and allied sets of libraries. To compartmentalize and reduce dependencies
- * I placed the Vaa3d specific use of this class into a separate set of
- * source files: loadV3dFFMpeg.h/cpp
- */
-
-
-#ifndef UINT64_C
-#define UINT64_C(c) (c ## ULL)
-#endif
-
-
-
-extern "C" {
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libavutil/pixfmt.h>
-#include <libavutil/opt.h>
-#include <libavutil/imgutils.h>
-
-#include <libswscale/swscale.h> //?
-}
-
-/*
-#include <QFile>
-#include <QNetworkAccessManager>
-#include <QMutex>
-#include <QUrl>
-#include <QBuffer>
-*/
-
-
-#include <string>
-#include <stdexcept>
-#include <iostream>
-#include <fstream>
-
-namespace libav {
-
-// Translated to C++ by Christopher Bruns May 2012
-// from ffmeg_adapt.c in whisk package by Nathan Clack, Mark Bolstadt, Michael Meeuwisse
- class decoder
- {
- public:
- enum Channel {
- RED = 0,
- GRAY = 0,
- GREEN = 1,
- BLUE = 2,
- ALPHA = 3
- };
-
- // Some libavcodec calls are not reentrant
- //static QMutex mutex;
- static void maybeInitFFMpegLib();
-
- decoder(PixelFormat pixelFormat=PIX_FMT_RGB24);
- //decoder(QUrl url, PixelFormat pixelFormat=PIX_FMT_RGB24);
- virtual ~decoder();
- //bool open(QUrl url, enum PixelFormat formatParam = PIX_FMT_RGB24);
- //bool open(QIODevice& fileStream, QString& fileName, enum PixelFormat formatParam = PIX_FMT_RGB24);
- uint8_t getPixelIntensity(int x, int y, Channel c = GRAY) const;
- bool fetchFrame(int targetFrameIndex = 0);
- int getNumberOfFrames() const;
- int getWidth() const;
- int getHeight() const;
- int getNumberOfChannels() const;
- bool readNextFrame(int targetFrameIndex = 0);
- bool readNextFrameWithPacket(int targetFrameIndex, AVPacket& packet, AVFrame* pYuv);
- int seekToFrame(int targetFrameIndex = 0);
-
- // make certain members public, for use by Fast3DTexture class
- AVFrame *pFrameRGB;
- AVFrame *pRaw;
- AVFormatContext *container;
- AVCodecContext *pCtx;
- int videoStream;
- int previousFrameIndex;
- bool isOpen;
-
- bool open(std::string& fileName, enum PixelFormat formatParam = PIX_FMT_RGB24);
- bool open(char* fileName, enum PixelFormat formatParam = PIX_FMT_RGB24);
-
- protected:
- static bool b_is_one_time_inited;
-
- void initialize();
-
- bool openUsingInitializedContainer(enum PixelFormat formatParam = PIX_FMT_RGB24 );
- static bool avtry(int result, const std::string& msg);
-
- AVCodec *pCodec;
- uint8_t *buffer,
- *blank;
- //struct
- SwsContext *Sctx;
- int width, height;
- PixelFormat format;
- size_t numBytes;
- int numFrames;
- int sc; // number of color channels
-
- // For loading from URL
- /*
- static const int ioBufferSize = 32768;
- unsigned char * ioBuffer;
- QNetworkAccessManager networkManager;
- AVIOContext* avioContext;
- QFile fileStream;
- QNetworkReply* reply;
- QBuffer fileBuffer;
- QByteArray byteArray;
- */
- };
-
-
- // TODO - finish refactoring based on
- // http://svn.gnumonks.org/trunk/21c3-video/ffmpeg/ffmpeg-0.4.9-pre1/output_example.c
- class encoder
- {
- public:
- //typedef encoder::Channel Channel;
-
- encoder(const char * file_name, int width, int height, enum AVCodecID codec_id = CODEC_ID_MPEG4);
- virtual ~encoder();
- void setPixelIntensity(int x, int y, int c, uint8_t value);
- void write_frame();
-
- protected:
- AVFormatContext *container;
- AVCodecContext *pCtx;
- AVFrame *picture_yuv;
- AVFrame *picture_rgb;
- struct SwsContext *Sctx;
- };
-}
-
-
-
-#endif // libavwrapper_H
diff --git a/libavwrapper/unit_test.cpp b/libavwrapper/unit_test.cpp
deleted file mode 100755
index 00070c8..0000000
--- a/libavwrapper/unit_test.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "unit_test.h"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- libav::decoder decoder;
-
- decoder.open("newsins1_360.mp4");
- cerr<<"opened movie file, "<<decoder.getWidth()<<"x"<<decoder.getHeight()<<", "<<decoder.getNumberOfFrames()<<" frames, "<<decoder.getNumberOfChannels()<<" channels"<<endl;
-
- cout << "hello, world!"<<endl;
- return 1;
-}
diff --git a/libavwrapper/unit_test.h b/libavwrapper/unit_test.h
deleted file mode 100755
index 41f5554..0000000
--- a/libavwrapper/unit_test.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "libavwrapper.h"
-
-#include <iostream> \ No newline at end of file
diff --git a/muxing/maker b/muxing/maker
deleted file mode 100755
index 1186c59..0000000
--- a/muxing/maker
+++ /dev/null
@@ -1 +0,0 @@
-gcc muxing.c -lavcodec -lavformat -lswscale -o muxing
diff --git a/muxing/muxing.c b/muxing/muxing.c
deleted file mode 100644
index e8b4ef7..0000000
--- a/muxing/muxing.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright (c) 2003 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * @file
- * libavformat API example.
- *
- * Output a media file in any supported libavformat format.
- * The default codecs are used.
- * @example doc/examples/muxing.c
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include <libavutil/mathematics.h>
-#include <libavformat/avformat.h>
-#include <libswscale/swscale.h>
-
-/* 5 seconds stream duration */
-#define STREAM_DURATION 20.0
-#define STREAM_FRAME_RATE 25 /* 25 images/s */
-#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
-#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */
-
-static int sws_flags = SWS_BICUBIC;
-
-/**************************************************************/
-/* audio output */
-
-static float t, tincr, tincr2;
-static int16_t *samples;
-static int audio_input_frame_size;
-
-/* Add an output stream. */
-static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
- enum AVCodecID codec_id)
-{
- AVCodecContext *c;
- AVStream *st;
-
- /* find the encoder */
- *codec = avcodec_find_encoder(codec_id);
- if (!(*codec)) {
- fprintf(stderr, "Could not find encoder for '%s'\n",
- avcodec_get_name(codec_id));
- exit(1);
- }
-
- st = avformat_new_stream(oc, *codec);
- if (!st) {
- fprintf(stderr, "Could not allocate stream\n");
- exit(1);
- }
- st->id = oc->nb_streams-1;
- c = st->codec;
-
- switch ((*codec)->type) {
- case AVMEDIA_TYPE_AUDIO:
- st->id = 1;
- c->sample_fmt = AV_SAMPLE_FMT_S16;
- c->bit_rate = 64000;
- c->sample_rate = 44100;
- c->channels = 2;
- break;
-
- case AVMEDIA_TYPE_VIDEO:
- c->codec_id = codec_id;
-
- c->bit_rate = 400000;
- /* Resolution must be a multiple of two. */
- c->width = 352;
- c->height = 288;
- /* timebase: This is the fundamental unit of time (in seconds) in terms
- * of which frame timestamps are represented. For fixed-fps content,
- * timebase should be 1/framerate and timestamp increments should be
- * identical to 1. */
- c->time_base.den = STREAM_FRAME_RATE;
- c->time_base.num = 1;
- c->gop_size = 12; /* emit one intra frame every twelve frames at most */
- c->pix_fmt = STREAM_PIX_FMT;
- if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- /* just for testing, we also add B frames */
- c->max_b_frames = 2;
- }
- if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
- /* Needed to avoid using macroblocks in which some coeffs overflow.
- * This does not happen with normal video, it just happens here as
- * the motion of the chroma plane does not match the luma plane. */
- c->mb_decision = 2;
- }
- break;
-
- default:
- break;
- }
-
- /* Some formats want stream headers to be separate. */
- if (oc->oformat->flags & AVFMT_GLOBALHEADER)
- c->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
- return st;
-}
-
-/**************************************************************/
-/* audio output */
-
-static float t, tincr, tincr2;
-static int16_t *samples;
-static int audio_input_frame_size;
-
-static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st)
-{
- AVCodecContext *c;
- int ret;
-
- c = st->codec;
-
- /* open it */
- ret = avcodec_open2(c, codec, NULL);
- if (ret < 0) {
- fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
- exit(1);
- }
-
- /* init signal generator */
- t = 0;
- tincr = 2 * M_PI * 110.0 / c->sample_rate;
- /* increment frequency by 110 Hz per second */
- tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
-
- if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)
- audio_input_frame_size = 10000;
- else
- audio_input_frame_size = c->frame_size;
- samples = av_malloc(audio_input_frame_size *
- av_get_bytes_per_sample(c->sample_fmt) *
- c->channels);
- if (!samples) {
- fprintf(stderr, "Could not allocate audio samples buffer\n");
- exit(1);
- }
-}
-
-/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
- * 'nb_channels' channels. */
-static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels)
-{
- int j, i, v;
- int16_t *q;
-
- q = samples;
- for (j = 0; j < frame_size; j++) {
- v = (int)(sin(t) * 10000);
- for (i = 0; i < nb_channels; i++)
- *q++ = v;
- t += tincr;
- tincr += tincr2;
- }
-}
-
-static void write_audio_frame(AVFormatContext *oc, AVStream *st)
-{
- AVCodecContext *c;
- AVPacket pkt = { 0 }; // data and size must be 0;
- AVFrame *frame = avcodec_alloc_frame();
- int got_packet, ret;
-
- av_init_packet(&pkt);
- c = st->codec;
-
- get_audio_frame(samples, audio_input_frame_size, c->channels);
- frame->nb_samples = audio_input_frame_size;
- avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
- (uint8_t *)samples,
- audio_input_frame_size *
- av_get_bytes_per_sample(c->sample_fmt) *
- c->channels, 1);
-
- ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
- if (ret < 0) {
- fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
- exit(1);
- }
-
- if (!got_packet)
- return;
-
- pkt.stream_index = st->index;
-
- /* Write the compressed frame to the media file. */
- ret = av_interleaved_write_frame(oc, &pkt);
- if (ret != 0) {
- fprintf(stderr, "Error while writing audio frame: %s\n",
- av_err2str(ret));
- exit(1);
- }
- avcodec_free_frame(&frame);
-}
-
-static void close_audio(AVFormatContext *oc, AVStream *st)
-{
- avcodec_close(st->codec);
-
- av_free(samples);
-}
-
-/**************************************************************/
-/* video output */
-
-static AVFrame *frame;
-static AVPicture src_picture, dst_picture;
-static int frame_count;
-
-static void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st)
-{
- int ret;
- AVCodecContext *c = st->codec;
-
- /* open the codec */
- ret = avcodec_open2(c, codec, NULL);
- if (ret < 0) {
- fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
- exit(1);
- }
-
- /* allocate and init a re-usable frame */
- frame = avcodec_alloc_frame();
- if (!frame) {
- fprintf(stderr, "Could not allocate video frame\n");
- exit(1);
- }
-
- /* Allocate the encoded raw picture. */
- ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height);
- if (ret < 0) {
- fprintf(stderr, "Could not allocate picture: %s\n", av_err2str(ret));
- exit(1);
- }
-
- /* If the output format is not YUV420P, then a temporary YUV420P
- * picture is needed too. It is then converted to the required
- * output format. */
- if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
- ret = avpicture_alloc(&src_picture, AV_PIX_FMT_YUV420P, c->width, c->height);
- if (ret < 0) {
- fprintf(stderr, "Could not allocate temporary picture: %s\n",
- av_err2str(ret));
- exit(1);
- }
- }
-
- /* copy data and linesize picture pointers to frame */
- *((AVPicture *)frame) = dst_picture;
-}
-
-/* Prepare a dummy image. */
-static void fill_yuv_image(AVPicture *pict, int frame_index,
- int width, int height)
-{
- int x, y, i;
-
- i = frame_index;
-
- /* Y */
- for (y = 0; y < height; y++)
- for (x = 0; x < width; x++)
- pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3;
-
- /* Cb and Cr */
- for (y = 0; y < height / 2; y++) {
- for (x = 0; x < width / 2; x++) {
- pict->data[1][y * pict->linesize[1] + x] = 128 + y + i * 2;
- pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5;
- }
- }
-}
-
-static void write_video_frame(AVFormatContext *oc, AVStream *st)
-{
- int ret;
- static struct SwsContext *sws_ctx;
- AVCodecContext *c = st->codec;
-
- if (frame_count >= STREAM_NB_FRAMES) {
- /* No more frames to compress. The codec has a latency of a few
- * frames if using B-frames, so we get the last frames by
- * passing the same picture again. */
- } else {
- if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
- /* as we only generate a YUV420P picture, we must convert it
- * to the codec pixel format if needed */
- if (!sws_ctx) {
- sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P,
- c->width, c->height, c->pix_fmt,
- sws_flags, NULL, NULL, NULL);
- if (!sws_ctx) {
- fprintf(stderr,
- "Could not initialize the conversion context\n");
- exit(1);
- }
- }
- fill_yuv_image(&src_picture, frame_count, c->width, c->height);
- sws_scale(sws_ctx,
- (const uint8_t * const *)src_picture.data, src_picture.linesize,
- 0, c->height, dst_picture.data, dst_picture.linesize);
- } else {
- fill_yuv_image(&dst_picture, frame_count, c->width, c->height);
- }
- }
-
- if (oc->oformat->flags & AVFMT_RAWPICTURE) {
- /* Raw video case - directly store the picture in the packet */
- AVPacket pkt;
- av_init_packet(&pkt);
-
- pkt.flags |= AV_PKT_FLAG_KEY;
- pkt.stream_index = st->index;
- pkt.data = dst_picture.data[0];
- pkt.size = sizeof(AVPicture);
-
- ret = av_interleaved_write_frame(oc, &pkt);
- } else {
- AVPacket pkt = { 0 };
- int got_packet;
- av_init_packet(&pkt);
-
- /* encode the image */
- ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
- if (ret < 0) {
- fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
- exit(1);
- }
- /* If size is zero, it means the image was buffered. */
-
- if (!ret && got_packet && pkt.size) {
- pkt.stream_index = st->index;
-
- /* Write the compressed frame to the media file. */
- ret = av_interleaved_write_frame(oc, &pkt);
- } else {
- ret = 0;
- }
- }
- if (ret != 0) {
- fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
- exit(1);
- }
- frame_count++;
-}
-
-static void close_video(AVFormatContext *oc, AVStream *st)
-{
- avcodec_close(st->codec);
- av_free(src_picture.data[0]);
- av_free(dst_picture.data[0]);
- av_free(frame);
-}
-
-/**************************************************************/
-/* media file output */
-
-int main(int argc, char **argv)
-{
- const char *filename;
- AVOutputFormat *fmt;
- AVFormatContext *oc;
- AVStream *audio_st, *video_st;
- AVCodec *audio_codec, *video_codec;
- double audio_pts, video_pts;
- int ret;
-
- /* Initialize libavcodec, and register all codecs and formats. */
- av_register_all();
-
- if (argc != 2) {
- printf("usage: %s output_file\n"
- "API example program to output a media file with libavformat.\n"
- "This program generates a synthetic audio and video stream, encodes and\n"
- "muxes them into a file named output_file.\n"
- "The output format is automatically guessed according to the file extension.\n"
- "Raw images can also be output by using '%%d' in the filename.\n"
- "\n", argv[0]);
- return 1;
- }
-
- filename = argv[1];
-
- /* allocate the output media context */
- avformat_alloc_output_context2(&oc, NULL, NULL, filename);
- if (!oc) {
- printf("Could not deduce output format from file extension: using MPEG.\n");
- avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
- }
- if (!oc) {
- return 1;
- }
- fmt = oc->oformat;
-
- /* Add the audio and video streams using the default format codecs
- * and initialize the codecs. */
- video_st = NULL;
- audio_st = NULL;
-
- if (fmt->video_codec != AV_CODEC_ID_NONE) {
- video_st = add_stream(oc, &video_codec, fmt->video_codec);
- }
- if (fmt->audio_codec != AV_CODEC_ID_NONE) {
- audio_st = add_stream(oc, &audio_codec, fmt->audio_codec);
- }
-
- /* Now that all the parameters are set, we can open the audio and
- * video codecs and allocate the necessary encode buffers. */
- if (video_st)
- open_video(oc, video_codec, video_st);
- if (audio_st)
- open_audio(oc, audio_codec, audio_st);
-
- av_dump_format(oc, 0, filename, 1);
-
- /* open the output file, if needed */
- if (!(fmt->flags & AVFMT_NOFILE)) {
- ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE);
- if (ret < 0) {
- fprintf(stderr, "Could not open '%s': %s\n", filename,
- av_err2str(ret));
- return 1;
- }
- }
-
- /* Write the stream header, if any. */
- ret = avformat_write_header(oc, NULL);
- if (ret < 0) {
- fprintf(stderr, "Error occurred when opening output file: %s\n",
- av_err2str(ret));
- return 1;
- }
-
- if (frame)
- frame->pts = 0;
- for (;;) {
- /* Compute current audio and video time. */
- if (audio_st)
- audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
- else
- audio_pts = 0.0;
-
- if (video_st)
- video_pts = (double)video_st->pts.val * video_st->time_base.num /
- video_st->time_base.den;
- else
- video_pts = 0.0;
-
- if ((!audio_st || audio_pts >= STREAM_DURATION) &&
- (!video_st || video_pts >= STREAM_DURATION))
- break;
-
- /* write interleaved audio and video frames */
- if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {
- write_audio_frame(oc, audio_st);
- } else {
- write_video_frame(oc, video_st);
- frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
- }
- }
-
- /* Write the trailer, if any. The trailer must be written before you
- * close the CodecContexts open when you wrote the header; otherwise
- * av_write_trailer() may try to use memory that was freed on
- * av_codec_close(). */
- av_write_trailer(oc);
-
- /* Close each codec. */
- if (video_st)
- close_video(oc, video_st);
- if (audio_st)
- close_audio(oc, audio_st);
-
- if (!(fmt->flags & AVFMT_NOFILE))
- /* Close the output file. */
- avio_close(oc->pb);
-
- /* free the stream */
- avformat_free_context(oc);
-
- return 0;
-}
diff --git a/opencv/Makefile b/opencv/Makefile
deleted file mode 100644
index 86ae740..0000000
--- a/opencv/Makefile
+++ /dev/null
@@ -1,253 +0,0 @@
-# The pre-processor and compiler options.
-
-#http://docs.gstreamer.com/display/GstSDK/Installing+on+Linux
-
-#MY_CFLAGS = -fpermissive -std=c++11 -Wno-error -I /opt/gstreamer-sdk/include/gstreamer-0.10/ -I /opt/gstreamer-sdk/include/glib-2.0 -I /opt/gstreamer-sdk/lib/glib-2.0/include -I /opt/gstreamer-sdk/include/libxml2 $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-MY_CFLAGS = -fpermissive -std=c++11 -I /usr/include/opencv
-#-Wno-error $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-
-# -I ../ffmpeg
-
-# The linker options.libgstaasinklibgstaasink.so
-MY_LIBS = -lopencv_core -lopencv_video -lopencv_highgui -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil -lstdc++ -lm
-#MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --libs)
-# -lgstreamer-0.10 -lgstreamer-video-0.10 -lgstreamer-base-0.10 -lglib-2.0 -lgstapp-0.10
-#MY_LIBS = ../libavcodec/ffmpeg/libavcodec/libavcodec.a ../libavcodec/ffmpeg/libavutil/libavutil.a ../libavcodec/ffmpeg/libavformat/libavformat.a ../libavcodec/ffmpeg/libavfilter/libavfilter.a ../libavcodec/ffmpeg/libavdevice/libavdevice.a -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk
-#GAH! HARD!
-
-# The pre-processor options used by the cpp (man cpp for more).
-CPPFLAGS = -Wall
-
-# The options used in linking as well as in any direct use of ld.
-LDFLAGS =
-
-# The directories in which source files reside.
-# If not specified, only the current directory will be serached.
-SRCDIRS =
-
-# The executable file name.
-# If not specified, current directory name or `a.out' will be used.
-PROGRAM =
-
-## Implicit Section: change the following only when necessary.
-##==========================================================================
-
-# The source file types (headers excluded).
-# .c indicates C source files, and others C++ ones.
-SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
-
-# The header file types.
-HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
-
-# The pre-processor and compiler options.
-# Users can override those variables from the command line.
-CFLAGS = -g -O2
-CXXFLAGS=
-CXX = colorgcc
-
-# The C program compiler.
-#CC = gcc
-
-# The C++ program compiler.
-#CXX = g++
-
-# Un-comment the following line to compile C programs as C++ ones.
-#CC = $(CXX)
-
-# The command used to delete file.
-RM = rm -f
-
-ETAGS = etags
-ETAGSFLAGS =
-
-CTAGS = ctags
-CTAGSFLAGS =
-
-## Stable Section: usually no need to be changed. But you can add more.
-##==========================================================================
-SHELL = /bin/sh
-EMPTY =
-SPACE = $(EMPTY) $(EMPTY)
-ifeq ($(PROGRAM),)
- CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
- PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
- ifeq ($(PROGRAM),)
- PROGRAM = a.out
- endif
-endif
-ifeq ($(SRCDIRS),)
- SRCDIRS = .
-endif
-SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
-HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
-SRC_CXX = $(filter-out %.c,$(SOURCES))
-OBJS = $(addsuffix .o, $(basename $(SOURCES)))
-DEPS = $(OBJS:.o=.d)
-
-## Define some useful variables.
-DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
- echo "-MM -MP"; else echo "-M"; fi )
-DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
-DEPEND.d = $(subst -g ,,$(DEPEND))
-COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c
-COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
-LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-.PHONY: all objs tags ctags clean distclean help show install
-
-# Delete the default suffixes
-.SUFFIXES:
-
-all: Release
-
-Clang: CXX = clang
-
-Clang: $(PROGRAM)
-
-Release: CXXFLAGS += -O2
-
-Release: $(PROGRAM)
-
-Debug: CXXFLAGS += -g3
-
-Debug: $(PROGRAM)
-
-prefix=/usr/local
-
-Install: rotord
- strip rotord
- install -m 0755 rotord $(prefix)/bin
-
-
-# Rules for creating dependency files (.d).
-#------------------------------------------
-
-%.d:%.c
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.C
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cc
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cpp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.CPP
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.c++
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cxx
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-# Rules for generating object files (.o).
-#----------------------------------------
-objs:$(OBJS)
-
-%.o:%.c
- $(COMPILE.c) $< -o $@
-
-%.o:%.C
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cc
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cpp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.CPP
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.c++
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cxx
- $(COMPILE.cxx) $< -o $@
-
-# Rules for generating the tags.
-#-------------------------------------
-tags: $(HEADERS) $(SOURCES)
- $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
-
-ctags: $(HEADERS) $(SOURCES)
- $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
-
-# Rules for generating the executable.
-#-------------------------------------
-$(PROGRAM):$(OBJS)
-ifeq ($(SRC_CXX),) # C program
- $(LINK.c) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-else # C++ program
- $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-endif
-
-ifndef NODEP
-ifneq ($(DEPS),)
- sinclude $(DEPS)
-endif
-endif
-
-
-clean:
- $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
-
-distclean: clean
- $(RM) $(DEPS) TAGS
-
-# Show help.
-help:
- @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
- @echo 'Copyright (C) 2007, 2008 whyglinux <whyglinux@hotmail.com>'
- @echo
- @echo 'Usage: make [TARGET]'
- @echo 'TARGETS:'
- @echo ' all (=make) compile and link.'
- @echo ' NODEP=yes make without generating dependencies.'
- @echo ' objs compile only (no linking).'
- @echo ' tags create tags for Emacs editor.'
- @echo ' ctags create ctags for VI editor.'
- @echo ' clean clean objects and the executable file.'
- @echo ' distclean clean objects, the executable and dependencies.'
- @echo ' show show variables (for debug use only).'
- @echo ' help print this message.'
- @echo
- @echo 'Report bugs to <whyglinux AT gmail DOT com>.'
-
-# Show variables (for debug use only.)
-show:
- @echo 'PROGRAM :' $(PROGRAM)
- @echo 'SRCDIRS :' $(SRCDIRS)
- @echo 'HEADERS :' $(HEADERS)
- @echo 'SOURCES :' $(SOURCES)
- @echo 'SRC_CXX :' $(SRC_CXX)
- @echo 'OBJS :' $(OBJS)
- @echo 'DEPS :' $(DEPS)
- @echo 'DEPEND :' $(DEPEND)
- @echo 'COMPILE.c :' $(COMPILE.c)
- @echo 'COMPILE.cxx :' $(COMPILE.cxx)
- @echo 'link.c :' $(LINK.c)
- @echo 'link.cxx :' $(LINK.cxx)
-
-## End of the Makefile ## Suggestions are welcome ## All rights reserved ##
-#############################################################################
diff --git a/opencv/cvimage.h b/opencv/cvimage.h
deleted file mode 100644
index 7588673..0000000
--- a/opencv/cvimage.h
+++ /dev/null
@@ -1,265 +0,0 @@
-#include <math.h>
-#include <cv.h>
-
-using namespace std;
-
-//converting to use a cv image...
-//cv::Mat supports most of what we want here
-//need to think
-//http://answers.opencv.org/question/8202/using-external-image-data-in-a-cvmat/
-
-//all access to the image is presently through a pointer to the data
-//cv::Mat supports this
-
-//how will copying work?
-//Rotor::Image will contain a cv::Mat object which may own its data or inherit it
-//cv::Mat should take care of reference counting
-
-//can cv::Mat
-
-namespace Rotor {
- class pixeltables{
- //handy pixel arithmetic lookup tables as nested arrays
- //so - pixels.add[0x78][0x66]; will give the precalculated result of adding with saturation
- // pixels.mono_weights[0][0x100]; will give the red component to convert to mono
- public:
- pixeltables(){
- add=new uint8_t*[256];
- multiply=new uint8_t*[256];
- for (int i=0;i<256;i++){
- add[i]=new uint8_t[256];
- multiply[i]=new uint8_t[256];
- for (int j=0;j<256;j++){
- add[i][j]=(uint8_t)min(i+j,0xFF);
- multiply[i][j]=(uint8_t)((((float)i)/255.0f)*(((float)j)/255.0f)*255.0f);
- }
- }
- mono_weights=new uint8_t*[3];
- float weights[3]={0.2989, 0.5870, 0.1140};
- for (int i=0;i<3;i++) {
- mono_weights[i]=new uint8_t[256];
- for (int j=0;j<256;j++){
- mono_weights[i][j]=(uint8_t)(((float)j)*weights[i]);
- }
- }
- }
- virtual ~pixeltables(){
- for (int i=0;i<256;i++){
- delete[] add[i];
- delete[] multiply[i];
- }
- delete[] add;
- delete[] multiply;
- for (int i=0;i<3;i++) {
- delete[] mono_weights[i];
- }
- delete[] mono_weights;
- }
- uint8_t **add;
- uint8_t **multiply;
- uint8_t **mono_weights;
- };
- static pixeltables pixels;
- class Image{
- public:
- Image(){
- zero();
- };
- Image(int _w,int _h){
- zero();
- setup(_w,_h);
- };
- ~Image() {
- free();
- };
- void free(){
- if (RGBdata&&ownsRGBdata) delete[] RGBdata;
- if (Adata&&ownsAdata) delete[] Adata;
- if (Zdata&&ownsZdata) delete[] Zdata;
- zero();
- }
- void zero(){
- RGBdata=nullptr;
- Adata=nullptr;
- Zdata=nullptr;
- w=0;
- h=0;
- ownsRGBdata=ownsAdata=ownsZdata=false;
- }
- bool setup(int _w,int _h){ //set up with internal data
- rgb.create(_w,_h,CV_8UC3);
- RGBdata=rgb.data; //can move to use the bare pointer eventually
- ownsRGBdata=false; //will not be necessary
- w=_w;
- h=_h;
- return true;
- /*
- if (w!=_w||h!=_h||!ownsRGBdata||!ownsAdata||!ownsZdata){
- free();
- w=_w;
- h=_h;
- RGBdata=new uint8_t[w*h*3];
- Adata=new uint8_t[w*h];
- Zdata=new uint16_t[w*h];
- ownsRGBdata=ownsAdata=ownsZdata=true;
- return true;
- }
- else return false;
- */
- }
- bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata){
- //here the data belongs to libavcodec or other
- //could move to using cv::Mat there also and just passing cv:Mat over
- rgb=cv::Mat(_w,_h,CV_8UC3,pRGBdata);
- RGBdata=rgb.data; //can move to use the bare pointer eventually
- ownsRGBdata=false; //will not be necessary
- w=_w;
- h=_h;
- return true;
- /*
- if (w!=_w||h!=_h||ownsRGBdata||!ownsAdata||!ownsZdata){
- free();
- w=_w;
- h=_h;
- RGBdata=pRGBdata;
- Adata=new uint8_t[w*h];
- Zdata=new uint16_t[w*h];
- ownsRGBdata=false;
- ownsAdata=ownsZdata=true;
- return true;
- }
- return false;
- */
- }
- bool setup_fromMat(cv::Mat& othermat){
- //here the mat belongs to another Image object
- rgb=cv::Mat(othermat);
- RGBdata=rgb.data; //can move to use the bare pointer eventually
- ownsRGBdata=false; //will not be necessary
- w=rgb.rows;
- h=rgb.cols;
- return true;
- }
- Image* clone(){
- Image *t=new Image();
- t->rgb=rgb.clone();
- t->w=w;
- t->h=h;
- t->RGBdata=t->rgb.data; //can move to use the bare pointer eventually
- t->ownsRGBdata=false; //will not be necessary
- /*
- for (int i=0;i<w*h*3;i++) {
- t->RGBdata[i]=RGBdata[i];
- }
- */
- return t;
- }
- //believe these still work, don't know if these optimisations are better than opencvs..
- Image & operator+=(const Image &other) {
- if (other.w!=w||other.h!=h) {
- cerr<<"Rotor: cannot add images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl;
- }
- else {
- for (int i=0;i<w*h*3;i++){
- //calculate with tables
- RGBdata[i]=pixels.add[RGBdata[i]][other.RGBdata[i]];
- }
- }
- return *this;
- }
- Image & operator*=(const Image &other) {
- if (other.w!=w||other.h!=h) {
- cerr<<"Rotor: cannot multiply images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl;
- }
- else {
- for (int i=0;i<w*h*3;i++){
- //calculate with tables
- RGBdata[i]=pixels.multiply[RGBdata[i]][other.RGBdata[i]];
- }
- }
- return *this;
- }
- Image & add_wrap(const Image &other) {
- if (other.w!=w||other.h!=h) {
- cerr<<"Rotor: cannot add images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl;
- }
- else {
- for (int i=0;i<w*h*3;i++){
- //creates rainbow overload
- RGBdata[i]=(unsigned char)(((int)other.RGBdata[i]+(int)RGBdata[i]));
- }
- }
- return *this;
- }
- //scalar operations allocate a new image.
- //maybe this could not be the case if the data is owned by this image?
- //need to look into auto_ptr
- Image & operator*=(const float &amount) {
- uint8_t *LUT=new uint8_t[256];
- for (int i=0;i<256;i++) {
- LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i*amount)));
- }
- for (int i=0;i<w*h*3;i++){
- //calculate with table
- RGBdata[i]=LUT[RGBdata[i]];
- }
- delete[] LUT;
- return *this;
- }
- Image * operator*(const float &amount) {
- Image *other=new Image(w,h);
- uint8_t *LUT=new uint8_t[256];
- for (int i=0;i<256;i++) {
- LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i*amount)));
- }
- for (int i=0;i<w*h*3;i++){
- other->RGBdata[i]=LUT[RGBdata[i]];
- }
- delete[] LUT;
- return other;
- }
- Image * operator+(const float &amount) {
- Image *other=new Image(w,h);
- uint8_t *LUT=new uint8_t[256];
- for (int i=0;i<256;i++) {
- LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i+(amount*255.0f))));
- }
- for (int i=0;i<w*h*3;i++){
- other->RGBdata[i]=LUT[RGBdata[i]];
- }
- delete[] LUT;
- return other;
- }
- Image * operator-(const float &amount) {
- Image *other=new Image(w,h);
- uint8_t *LUT=new uint8_t[256];
- for (int i=0;i<256;i++) {
- LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i-(amount*255.0f))));
- }
- for (int i=0;i<w*h*3;i++){
- other->RGBdata[i]=LUT[RGBdata[i]];
- }
- delete[] LUT;
- return other;
- }
- Image * operator/(const float &amount) {
- Image *other=new Image(w,h);
- uint8_t *LUT=new uint8_t[256];
- for (int i=0;i<256;i++) {
- LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i/amount)));
- }
- for (int i=0;i<w*h*3;i++){
- other->RGBdata[i]=LUT[RGBdata[i]];
- }
- delete[] LUT;
- return other;
- }
- uint8_t *RGBdata;
- uint8_t *Adata;
- uint16_t *Zdata;
- int h,w;
- bool ownsRGBdata,ownsAdata,ownsZdata; //better done through auto_ptr?
-
- cv::Mat rgb;
- };
-} \ No newline at end of file
diff --git a/opencv/hello-opencv.cpp b/opencv/hello-opencv.cpp
deleted file mode 100644
index 8f0c566..0000000
--- a/opencv/hello-opencv.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-////////////////////////////////////////////////////////////////////////
-//
-// hello-world.cpp
-//
-// This is a simple, introductory OpenCV program. The program reads an
-// image from a file, inverts it, and displays the result.
-//
-////////////////////////////////////////////////////////////////////////
-
-//plan:
-//incorporate opencv images into the Rotor::image class
-//initially:: update to support existing operations
-//should all functionality that accesses image pixels be a part of the image class?
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <highgui.h>
-
-#include "cvimage.h"
-
-
-int main(int argc, char *argv[])
-{
- IplImage* img = 0;
- int height,width,step,channels;
- uchar *data;
- int i,j,k;
-
- if(argc<2){
- printf("Usage: main <image-file-name>\n\7");
- exit(0);
- }
-
- // load an image
- img=cvLoadImage(argv[1]);
- if(!img){
- printf("Could not load image file: %s\n",argv[1]);
- exit(0);
- }
-
- // get the image data
- height = img->height;
- width = img->width;
- step = img->widthStep;
- channels = img->nChannels;
- data = (uchar *)img->imageData;
- printf("Processing a %dx%d image with %d channels\n",height,width,channels);
-
- // create a window
- cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
- cvMoveWindow("mainWin", 100, 100);
-
- // invert the image
- for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
- data[i*step+j*channels+k]=255-data[i*step+j*channels+k];
-
- // show the image
- cvShowImage("mainWin", img );
-
- // wait for a key
- cvWaitKey(0);
-
- // release the image
- cvReleaseImage(&img );
- return 0;
-}
diff --git a/opencv/hello-opencv.d b/opencv/hello-opencv.d
deleted file mode 100644
index c7b95b9..0000000
--- a/opencv/hello-opencv.d
+++ /dev/null
@@ -1,196 +0,0 @@
-./hello-opencv.o: hello-opencv.cpp /usr/include/stdlib.h \
- /usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
- /usr/include/i386-linux-gnu/sys/cdefs.h \
- /usr/include/i386-linux-gnu/bits/wordsize.h \
- /usr/include/i386-linux-gnu/gnu/stubs.h \
- /usr/include/i386-linux-gnu/gnu/stubs-32.h \
- /usr/lib/gcc/i686-linux-gnu/4.7/include/stddef.h \
- /usr/include/i386-linux-gnu/bits/waitflags.h \
- /usr/include/i386-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
- /usr/include/i386-linux-gnu/bits/endian.h \
- /usr/include/i386-linux-gnu/bits/byteswap.h /usr/include/xlocale.h \
- /usr/include/i386-linux-gnu/sys/types.h \
- /usr/include/i386-linux-gnu/bits/types.h \
- /usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
- /usr/include/i386-linux-gnu/sys/select.h \
- /usr/include/i386-linux-gnu/bits/select.h \
- /usr/include/i386-linux-gnu/bits/sigset.h \
- /usr/include/i386-linux-gnu/bits/time.h \
- /usr/include/i386-linux-gnu/bits/select2.h \
- /usr/include/i386-linux-gnu/sys/sysmacros.h \
- /usr/include/i386-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
- /usr/include/i386-linux-gnu/bits/stdlib.h /usr/include/stdio.h \
- /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
- /usr/lib/gcc/i686-linux-gnu/4.7/include/stdarg.h \
- /usr/include/i386-linux-gnu/bits/stdio_lim.h \
- /usr/include/i386-linux-gnu/bits/sys_errlist.h \
- /usr/include/i386-linux-gnu/bits/stdio.h \
- /usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/math.h \
- /usr/include/i386-linux-gnu/bits/huge_val.h \
- /usr/include/i386-linux-gnu/bits/huge_valf.h \
- /usr/include/i386-linux-gnu/bits/huge_vall.h \
- /usr/include/i386-linux-gnu/bits/inf.h \
- /usr/include/i386-linux-gnu/bits/nan.h \
- /usr/include/i386-linux-gnu/bits/mathdef.h \
- /usr/include/i386-linux-gnu/bits/mathcalls.h \
- /usr/include/i386-linux-gnu/bits/mathinline.h \
- /usr/include/opencv/highgui.h /usr/include/opencv2/core/core_c.h \
- /usr/include/opencv2/core/types_c.h /usr/include/assert.h \
- /usr/include/string.h /usr/include/i386-linux-gnu/bits/string3.h \
- /usr/lib/gcc/i686-linux-gnu/4.7/include/float.h \
- /usr/lib/gcc/i686-linux-gnu/4.7/include/stdint.h /usr/include/stdint.h \
- /usr/include/i386-linux-gnu/bits/wchar.h \
- /usr/include/opencv2/core/core.hpp /usr/include/opencv2/core/version.hpp \
- /usr/lib/gcc/i686-linux-gnu/4.7/include-fixed/limits.h \
- /usr/lib/gcc/i686-linux-gnu/4.7/include-fixed/syslimits.h \
- /usr/include/limits.h /usr/include/i386-linux-gnu/bits/posix1_lim.h \
- /usr/include/i386-linux-gnu/bits/local_lim.h /usr/include/linux/limits.h \
- /usr/include/i386-linux-gnu/bits/posix2_lim.h \
- /usr/include/i386-linux-gnu/bits/xopen_lim.h \
- /usr/include/c++/4.7/algorithm /usr/include/c++/4.7/utility \
- /usr/include/c++/4.7/i686-linux-gnu/bits/c++config.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/os_defines.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/cpu_defines.h \
- /usr/include/c++/4.7/bits/stl_relops.h \
- /usr/include/c++/4.7/bits/stl_pair.h /usr/include/c++/4.7/bits/move.h \
- /usr/include/c++/4.7/bits/concept_check.h \
- /usr/include/c++/4.7/type_traits /usr/include/c++/4.7/initializer_list \
- /usr/include/c++/4.7/bits/stl_algobase.h \
- /usr/include/c++/4.7/bits/functexcept.h \
- /usr/include/c++/4.7/bits/exception_defines.h \
- /usr/include/c++/4.7/bits/cpp_type_traits.h \
- /usr/include/c++/4.7/ext/type_traits.h \
- /usr/include/c++/4.7/ext/numeric_traits.h \
- /usr/include/c++/4.7/bits/stl_iterator_base_types.h \
- /usr/include/c++/4.7/bits/stl_iterator_base_funcs.h \
- /usr/include/c++/4.7/bits/stl_iterator.h \
- /usr/include/c++/4.7/debug/debug.h /usr/include/c++/4.7/bits/stl_algo.h \
- /usr/include/c++/4.7/cstdlib /usr/include/c++/4.7/bits/algorithmfwd.h \
- /usr/include/c++/4.7/bits/stl_heap.h \
- /usr/include/c++/4.7/bits/stl_tempbuf.h \
- /usr/include/c++/4.7/bits/stl_construct.h /usr/include/c++/4.7/new \
- /usr/include/c++/4.7/exception \
- /usr/include/c++/4.7/bits/atomic_lockfree_defines.h \
- /usr/include/c++/4.7/bits/exception_ptr.h \
- /usr/include/c++/4.7/bits/nested_exception.h \
- /usr/include/c++/4.7/ext/alloc_traits.h \
- /usr/include/c++/4.7/bits/alloc_traits.h \
- /usr/include/c++/4.7/bits/ptr_traits.h /usr/include/c++/4.7/random \
- /usr/include/c++/4.7/cmath /usr/include/c++/4.7/cstdio \
- /usr/include/c++/4.7/string /usr/include/c++/4.7/bits/stringfwd.h \
- /usr/include/c++/4.7/bits/char_traits.h \
- /usr/include/c++/4.7/bits/postypes.h /usr/include/c++/4.7/cwchar \
- /usr/include/i386-linux-gnu/bits/wchar2.h /usr/include/c++/4.7/cstdint \
- /usr/include/c++/4.7/bits/allocator.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/c++allocator.h \
- /usr/include/c++/4.7/ext/new_allocator.h \
- /usr/include/c++/4.7/bits/localefwd.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/c++locale.h \
- /usr/include/c++/4.7/clocale /usr/include/locale.h \
- /usr/include/i386-linux-gnu/bits/locale.h /usr/include/c++/4.7/iosfwd \
- /usr/include/c++/4.7/cctype /usr/include/ctype.h \
- /usr/include/c++/4.7/bits/ostream_insert.h \
- /usr/include/c++/4.7/bits/cxxabi_forced.h \
- /usr/include/c++/4.7/bits/stl_function.h \
- /usr/include/c++/4.7/backward/binders.h \
- /usr/include/c++/4.7/bits/range_access.h \
- /usr/include/c++/4.7/bits/basic_string.h \
- /usr/include/c++/4.7/ext/atomicity.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/gthr.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/gthr-default.h \
- /usr/include/pthread.h /usr/include/sched.h \
- /usr/include/i386-linux-gnu/bits/sched.h \
- /usr/include/i386-linux-gnu/bits/timex.h \
- /usr/include/i386-linux-gnu/bits/setjmp.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/atomic_word.h \
- /usr/include/c++/4.7/ext/string_conversions.h \
- /usr/include/c++/4.7/cerrno /usr/include/errno.h \
- /usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
- /usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
- /usr/include/asm-generic/errno-base.h \
- /usr/include/c++/4.7/bits/functional_hash.h \
- /usr/include/c++/4.7/bits/hash_bytes.h \
- /usr/include/c++/4.7/bits/basic_string.tcc /usr/include/c++/4.7/limits \
- /usr/include/c++/4.7/bits/random.h /usr/include/c++/4.7/vector \
- /usr/include/c++/4.7/bits/stl_uninitialized.h \
- /usr/include/c++/4.7/bits/stl_vector.h \
- /usr/include/c++/4.7/bits/stl_bvector.h \
- /usr/include/c++/4.7/bits/vector.tcc \
- /usr/include/c++/4.7/bits/random.tcc /usr/include/c++/4.7/numeric \
- /usr/include/c++/4.7/bits/stl_numeric.h /usr/include/c++/4.7/functional \
- /usr/include/c++/4.7/typeinfo /usr/include/c++/4.7/tuple \
- /usr/include/c++/4.7/bits/uses_allocator.h /usr/include/c++/4.7/cstddef \
- /usr/include/c++/4.7/complex /usr/include/c++/4.7/sstream \
- /usr/include/c++/4.7/istream /usr/include/c++/4.7/ios \
- /usr/include/c++/4.7/bits/ios_base.h \
- /usr/include/c++/4.7/bits/locale_classes.h \
- /usr/include/c++/4.7/bits/locale_classes.tcc \
- /usr/include/c++/4.7/streambuf /usr/include/c++/4.7/bits/streambuf.tcc \
- /usr/include/c++/4.7/bits/basic_ios.h \
- /usr/include/c++/4.7/bits/locale_facets.h /usr/include/c++/4.7/cwctype \
- /usr/include/wctype.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/ctype_base.h \
- /usr/include/c++/4.7/bits/streambuf_iterator.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/ctype_inline.h \
- /usr/include/c++/4.7/bits/locale_facets.tcc \
- /usr/include/c++/4.7/bits/basic_ios.tcc /usr/include/c++/4.7/ostream \
- /usr/include/c++/4.7/bits/ostream.tcc \
- /usr/include/c++/4.7/bits/istream.tcc \
- /usr/include/c++/4.7/bits/sstream.tcc /usr/include/c++/4.7/map \
- /usr/include/c++/4.7/bits/stl_tree.h /usr/include/c++/4.7/bits/stl_map.h \
- /usr/include/c++/4.7/bits/stl_multimap.h \
- /usr/include/opencv2/core/operations.hpp \
- /usr/include/opencv2/core/mat.hpp \
- /usr/include/opencv2/highgui/highgui_c.h \
- /usr/include/opencv2/highgui/highgui.hpp cvimage.h \
- /usr/include/opencv/cv.h /usr/include/opencv2/imgproc/imgproc_c.h \
- /usr/include/opencv2/imgproc/types_c.h \
- /usr/include/opencv2/imgproc/imgproc.hpp \
- /usr/include/opencv2/video/tracking.hpp \
- /usr/include/opencv2/features2d/features2d.hpp \
- /usr/include/opencv2/flann/miniflann.hpp \
- /usr/include/opencv2/flann/defines.h /usr/include/opencv2/flann/config.h \
- /usr/include/opencv2/flann/flann.hpp \
- /usr/include/opencv2/flann/flann_base.hpp /usr/include/c++/4.7/cassert \
- /usr/include/opencv2/flann/general.h \
- /usr/include/opencv2/flann/defines.h /usr/include/c++/4.7/stdexcept \
- /usr/include/opencv2/flann/matrix.h /usr/include/opencv2/flann/params.h \
- /usr/include/opencv2/flann/any.h /usr/include/c++/4.7/iostream \
- /usr/include/opencv2/flann/saving.h /usr/include/c++/4.7/cstring \
- /usr/include/opencv2/flann/nn_index.h \
- /usr/include/opencv2/flann/result_set.h /usr/include/c++/4.7/set \
- /usr/include/c++/4.7/bits/stl_set.h \
- /usr/include/c++/4.7/bits/stl_multiset.h \
- /usr/include/opencv2/flann/all_indices.h \
- /usr/include/opencv2/flann/kdtree_index.h \
- /usr/include/opencv2/flann/dynamic_bitset.h \
- /usr/include/opencv2/flann/dist.h /usr/include/opencv2/flann/heap.h \
- /usr/include/opencv2/flann/allocator.h \
- /usr/include/opencv2/flann/random.h \
- /usr/include/opencv2/flann/kdtree_single_index.h \
- /usr/include/opencv2/flann/kmeans_index.h \
- /usr/include/opencv2/flann/logger.h \
- /usr/include/opencv2/flann/composite_index.h \
- /usr/include/opencv2/flann/linear_index.h \
- /usr/include/opencv2/flann/hierarchical_clustering_index.h \
- /usr/include/opencv2/flann/lsh_index.h \
- /usr/include/opencv2/flann/lsh_table.h /usr/include/c++/4.7/iomanip \
- /usr/include/c++/4.7/locale \
- /usr/include/c++/4.7/bits/locale_facets_nonio.h \
- /usr/include/c++/4.7/ctime \
- /usr/include/c++/4.7/i686-linux-gnu/bits/time_members.h \
- /usr/include/c++/4.7/i686-linux-gnu/bits/messages_members.h \
- /usr/include/libintl.h /usr/include/c++/4.7/bits/codecvt.h \
- /usr/include/c++/4.7/bits/locale_facets_nonio.tcc \
- /usr/include/opencv2/flann/autotuned_index.h \
- /usr/include/opencv2/flann/ground_truth.h \
- /usr/include/opencv2/flann/index_testing.h \
- /usr/include/opencv2/flann/timer.h /usr/include/opencv2/flann/sampling.h \
- /usr/include/opencv2/calib3d/calib3d.hpp \
- /usr/include/opencv2/objdetect/objdetect.hpp /usr/include/c++/4.7/deque \
- /usr/include/c++/4.7/bits/stl_deque.h \
- /usr/include/c++/4.7/bits/deque.tcc \
- /usr/include/opencv2/legacy/compat.hpp \
- /usr/include/opencv2/core/internal.hpp \
- /usr/include/i386-linux-gnu/sys/mman.h \
- /usr/include/i386-linux-gnu/bits/mman.h
diff --git a/opencv/hello-opencv.o b/opencv/hello-opencv.o
deleted file mode 100644
index 94daefd..0000000
--- a/opencv/hello-opencv.o
+++ /dev/null
Binary files differ
diff --git a/opencv/opencv b/opencv/opencv
deleted file mode 100755
index 165ab7e..0000000
--- a/opencv/opencv
+++ /dev/null
Binary files differ
diff --git a/processmodel/Makefile b/processmodel/Makefile
deleted file mode 100644
index d2546e0..0000000
--- a/processmodel/Makefile
+++ /dev/null
@@ -1,252 +0,0 @@
-# The pre-processor and compiler options.
-
-#http://docs.gstreamer.com/display/GstSDK/Installing+on+Linux
-
-#MY_CFLAGS = -fpermissive -std=c++11 -Wno-error -I /opt/gstreamer-sdk/include/gstreamer-0.10/ -I /opt/gstreamer-sdk/include/glib-2.0 -I /opt/gstreamer-sdk/lib/glib-2.0/include -I /opt/gstreamer-sdk/include/libxml2 $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-MY_CFLAGS = -fpermissive -std=c++11
-#-Wno-error $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-
-# -I ../ffmpeg
-
-# The linker options.libgstaasinklibgstaasink.so
-MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil
-#MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --libs)
-# -lgstreamer-0.10 -lgstreamer-video-0.10 -lgstreamer-base-0.10 -lglib-2.0 -lgstapp-0.10
-#MY_LIBS = ../libavcodec/ffmpeg/libavcodec/libavcodec.a ../libavcodec/ffmpeg/libavutil/libavutil.a ../libavcodec/ffmpeg/libavformat/libavformat.a ../libavcodec/ffmpeg/libavfilter/libavfilter.a ../libavcodec/ffmpeg/libavdevice/libavdevice.a -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk
-#GAH! HARD!
-
-# The pre-processor options used by the cpp (man cpp for more).
-CPPFLAGS = -Wall
-
-# The options used in linking as well as in any direct use of ld.
-LDFLAGS =
-
-# The directories in which source files reside.
-# If not specified, only the current directory will be serached.
-SRCDIRS =
-
-# The executable file name.
-# If not specified, current directory name or `a.out' will be used.
-PROGRAM =
-
-## Implicit Section: change the following only when necessary.
-##==========================================================================
-
-# The source file types (headers excluded).
-# .c indicates C source files, and others C++ ones.
-SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
-
-# The header file types.
-HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
-
-# The pre-processor and compiler options.
-# Users can override those variables from the command line.
-CFLAGS = -g -O2
-CXXFLAGS=
-
-# The C program compiler.
-#CC = gcc
-
-# The C++ program compiler.
-#CXX = g++
-
-# Un-comment the following line to compile C programs as C++ ones.
-#CC = $(CXX)
-
-# The command used to delete file.
-RM = rm -f
-
-ETAGS = etags
-ETAGSFLAGS =
-
-CTAGS = ctags
-CTAGSFLAGS =
-
-## Stable Section: usually no need to be changed. But you can add more.
-##==========================================================================
-SHELL = /bin/sh
-EMPTY =
-SPACE = $(EMPTY) $(EMPTY)
-ifeq ($(PROGRAM),)
- CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
- PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
- ifeq ($(PROGRAM),)
- PROGRAM = a.out
- endif
-endif
-ifeq ($(SRCDIRS),)
- SRCDIRS = .
-endif
-SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
-HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
-SRC_CXX = $(filter-out %.c,$(SOURCES))
-OBJS = $(addsuffix .o, $(basename $(SOURCES)))
-DEPS = $(OBJS:.o=.d)
-
-## Define some useful variables.
-DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
- echo "-MM -MP"; else echo "-M"; fi )
-DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
-DEPEND.d = $(subst -g ,,$(DEPEND))
-COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c
-COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
-LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-.PHONY: all objs tags ctags clean distclean help show install
-
-# Delete the default suffixes
-.SUFFIXES:
-
-all: Release
-
-Clang: CXX = clang
-
-Clang: $(PROGRAM)
-
-Release: CXXFLAGS += -O2
-
-Release: $(PROGRAM)
-
-Debug: CXXFLAGS += -g3
-
-Debug: $(PROGRAM)
-
-prefix=/usr/local
-
-Install: rotord
- strip rotord
- install -m 0755 rotord $(prefix)/bin
-
-
-# Rules for creating dependency files (.d).
-#------------------------------------------
-
-%.d:%.c
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.C
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cc
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cpp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.CPP
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.c++
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cxx
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-# Rules for generating object files (.o).
-#----------------------------------------
-objs:$(OBJS)
-
-%.o:%.c
- $(COMPILE.c) $< -o $@
-
-%.o:%.C
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cc
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cpp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.CPP
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.c++
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cxx
- $(COMPILE.cxx) $< -o $@
-
-# Rules for generating the tags.
-#-------------------------------------
-tags: $(HEADERS) $(SOURCES)
- $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
-
-ctags: $(HEADERS) $(SOURCES)
- $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
-
-# Rules for generating the executable.
-#-------------------------------------
-$(PROGRAM):$(OBJS)
-ifeq ($(SRC_CXX),) # C program
- $(LINK.c) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-else # C++ program
- $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-endif
-
-ifndef NODEP
-ifneq ($(DEPS),)
- sinclude $(DEPS)
-endif
-endif
-
-
-clean:
- $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
-
-distclean: clean
- $(RM) $(DEPS) TAGS
-
-# Show help.
-help:
- @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
- @echo 'Copyright (C) 2007, 2008 whyglinux <whyglinux@hotmail.com>'
- @echo
- @echo 'Usage: make [TARGET]'
- @echo 'TARGETS:'
- @echo ' all (=make) compile and link.'
- @echo ' NODEP=yes make without generating dependencies.'
- @echo ' objs compile only (no linking).'
- @echo ' tags create tags for Emacs editor.'
- @echo ' ctags create ctags for VI editor.'
- @echo ' clean clean objects and the executable file.'
- @echo ' distclean clean objects, the executable and dependencies.'
- @echo ' show show variables (for debug use only).'
- @echo ' help print this message.'
- @echo
- @echo 'Report bugs to <whyglinux AT gmail DOT com>.'
-
-# Show variables (for debug use only.)
-show:
- @echo 'PROGRAM :' $(PROGRAM)
- @echo 'SRCDIRS :' $(SRCDIRS)
- @echo 'HEADERS :' $(HEADERS)
- @echo 'SOURCES :' $(SOURCES)
- @echo 'SRC_CXX :' $(SRC_CXX)
- @echo 'OBJS :' $(OBJS)
- @echo 'DEPS :' $(DEPS)
- @echo 'DEPEND :' $(DEPEND)
- @echo 'COMPILE.c :' $(COMPILE.c)
- @echo 'COMPILE.cxx :' $(COMPILE.cxx)
- @echo 'link.c :' $(LINK.c)
- @echo 'link.cxx :' $(LINK.cxx)
-
-## End of the Makefile ## Suggestions are welcome ## All rights reserved ##
-#############################################################################
diff --git a/processmodel/processmodel.cpp b/processmodel/processmodel.cpp
deleted file mode 100644
index ec78099..0000000
--- a/processmodel/processmodel.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-#include "processmodel.h"
-
-//1. make a basic executable that represents a render context
-//get message passing going
-//incorporate in REST server
-//fill in the details
-
-RotorRequestHandler::RotorRequestHandler(const std::string& format): _format(format){
-}
-
-void RotorRequestHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) {
-
- Timestamp now;
- std::string dt(DateTimeFormatter::format(now, _format));
-
- response.setChunkedTransferEncoding(true);
- response.setContentType("text/html");
-
- std::ostream& ostr = response.send();
- ostr << "<html><head><title>RotorServer powered by "
- "POCO C++ Libraries</title>";
- ostr << "</head>";
- ostr << "<body><p style=\"text-align: center; "
- "font-size: 48px;\">";
- ostr << dt;
- ostr << "</p></body></html>";
-}
-
-
-AudioAnalyserHandler::AudioAnalyserHandler(const vampHost::Settings& _settings): settings(_settings){
-}
-
-void AudioAnalyserHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) {
-
- response.setChunkedTransferEncoding(true);
- response.setContentType("text/html");
-
- //string audioData=vampHost::runPlugin();
-
- std::ostream& ostr = response.send();
- ostr << "<html><head><title>RotorServer powered by "
- "POCO C++ Libraries</title>";
- ostr << "</head>";
- ostr << "<body><p style=\"text-align: center; "
- "font-size: 48px;\">";
- vampHost::runPlugin("",settings.soname,settings.filtername, "",0, settings.inputFile, ostr,true);
- ostr << "</p></body></html>";
-}
-
-RenderContextHandler::RenderContextHandler(const std::string _content,const HTTPServerResponse::HTTPStatus _status){
- content=_content;
- status=_status;
-}
-
-
-void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) {
-
- response.setChunkedTransferEncoding(true);
- response.setContentType("text/html");
- response.setStatus(status);
-
- std::ostream& ostr = response.send();
-
- ostr << "<?xml version='1.0' encoding='ISO-8859-1'?>\n";
- ostr << content;
-
-}
-
-
-HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){
- Application& app = Application::instance();
-
- Poco::URI theuri=Poco::URI(request.getURI());
- std::vector <std::string> command;
- theuri.getPathSegments(command);
-
- app.logger().information(request.clientAddress().toString()+" "+request.getMethod());
-
- string content="";
- HTTPResponse::HTTPStatus status=HTTPResponse::HTTP_BAD_REQUEST; //by default
-
- std::string body;
- std::ostringstream os;
- os<<request.stream().rdbuf();
- body=os.str();
-
- /*
-
- if (command.size()) {
- if (command[0]=="new") {
- if (request.getMethod()=="GET") {
- string sID=idGen.createOne().toString(); //create() seems to cause problems
- //Creates a new time-based UUID, using the MAC address of one of the system's ethernet adapters.
- //Throws a SystemException if no MAC address can be obtained.
- //
- //seems to hang, to me
- cerr << "Rotor: starting thread "<< sID << endl;
- manager.start(new Rotor::Render_context(sID));
- content="<sID>"+sID+"</sID>\n";
- status=HTTPResponse::HTTP_OK;
- }
- if (request.getMethod()=="PUT") { //undocumented manual thread name
- if (body.size()) {
- string sID=body;
- cerr << "Rotor: starting thread "<< sID << endl;
- manager.start(new Rotor::Render_context(sID));
- content="<sID>"+sID+"</sID>\n";
- status=HTTPResponse::HTTP_OK;
- }
- }
- }
- else if (command[0]=="list") {
- if (request.getMethod()=="GET") {
- //std::list < Poco::AutoPtr < Poco::Task > >::iterator it;
- //it=manager.taskList().begin();
- //for (it=manager.taskList().begin();it !=manager.taskList().end();++it) {
- //content+="<sID>"+(*it)->name()+"</sID>\n";
- //}
-
- //massive problems making an iterator for the tasklist, the above crashes
- //solution: auto type range-based for-loop
- //this is c++11 specific but works
-
- for (auto& task: manager.taskList()) { //c++11
- content+="<sID>"+task->name()+" </sID>\n";
- }
- status=HTTPResponse::HTTP_OK;
- }
- }
- else if (command[0]=="styles") {
- //eventually retrieve from sql;
- //a bit of weirdness here: prefer to just get whole file to a string.
- if (request.getMethod()=="GET") {
- std::string stylesfile = "styles.xml";
- Poco::File f=Poco::File(stylesfile);
- if (f.exists()) {
- Poco::FileInputStream file(stylesfile);
- //while (!file.eof()) {
- // file >> content;
- //}
- Poco::StreamCopier::copyToString(file, content);
- status=HTTPResponse::HTTP_OK;
- }
- else {
- content="<status>Rotor: internal error: styles not found</status>\n";
- }
-
- }
- else {
- content="<status>Rotor: bad request</status>\n";
- }
- }
- else if (command[0]=="exit") {
- exit(0);
- }
- else {
- bool found=false;
- for (auto& task: manager.taskList()) { //c++11
- if(task->name()==command[0]) {
- //valid session command
- found=true;
- if (command.size()==1) {
- //just invoking sID
- if (request.getMethod()=="DELETE") {
- task->cancel();
- content="<status>1</status>\n";
- status=HTTPResponse::HTTP_OK;
- }
- else {
- content="<status>Rotor: render context invoked with no command</status>\n";
- }
- }
- else { //session modifier command- to be passed to render context
- //some commands need to return error codes
- //ie where the audio file isn't found
- //on the other hand, some commands need to know state of the renderer?
-
-
- vector<string> sc; //method,id,command1,{command2,}{body}
- sc.push_back(request.getMethod());
- for (auto& i: command){
- sc.push_back(i);
- }
- sc.push_back(body);
-
- Rotor::Command_response response=((Poco::AutoPtr<Rotor::Render_context>)task)->session_command(sc);
-
- content=response.description;
- status=response.status;
-
- }
- }
- }
- if (!found) {
- status=HTTPResponse::HTTP_NOT_FOUND;
- content="<status>Rotor: render context not found</status>\n";
- }
- }
- }
- else {
- content="<status>Rotor: empty request</status>";
- }
- */
- return new RenderContextHandler(content, status);
-}
-
-
-RotorServer::RotorServer(): _helpRequested(false)
-{
-}
-
-RotorServer::~RotorServer()
-{
-}
-
-void RotorServer::initialize(Application& self){
- loadConfiguration();
- ServerApplication::initialize(self);
-}
-
-void RotorServer::uninitialize(){
- ServerApplication::uninitialize();
-}
-
-void RotorServer::defineOptions(OptionSet& options) {
- ServerApplication::defineOptions(options);
- options.addOption(
- Option("help", "h", "display argument help information")
- .required(false)
- .repeatable(false)
- .callback(OptionCallback<RotorServer>(this, &RotorServer::handleHelp)
- )
- );
-}
-
-void RotorServer::handleHelp(const std::string& name, const std::string& value){
- HelpFormatter helpFormatter(options());
- helpFormatter.setCommand(commandName());
- helpFormatter.setUsage("OPTIONS");
- helpFormatter.setHeader(
- "Rotor");
- helpFormatter.format(std::cout);
- stopOptionsProcessing();
- _helpRequested = true;
-}
-
-int main(int argc, char** argv)
-{
-
- std::vector<std::string> args;
- args.push_back("-ax");
- if (argc>1) {
- std::string cmd=std::string(argv[1]);
- Poco::Pipe outPipe;
- Poco::Pipe inPipe;
- ProcessHandle ph = Process::launch(cmd, args, &inPipe, &outPipe, 0);
- Poco::PipeInputStream istr(outPipe);
- Poco::PipeOutputStream ostr(inPipe);
- //std::ofstream ostr("processes.txt");
- //
- while (true){
- Poco::StreamCopier::copyStream(istr,std::cout);
- //ostr<<std::cin;
- //std::cout<<istr;
- }
- return 0;
- }
- else std::cerr<<"usage: processmodel [executable]"<<std::endl;
-}
-
-
-int RotorServer::main(const std::vector<std::string>& args){
- if (!_helpRequested) {
-
- unsigned short port;
-
- xmlIO xml;
- if(xml.loadFile("settings.xml") ){
- port=xml.getAttribute("Rotor","port",9980,0);
- }
- else cerr<<"Rotord: settings.xml not found, using defaults"<<endl;
-
- port = (unsigned short) config().getInt("port", port); //override from command line
-
- std::string format(config().getString("format", DateTimeFormat::SORTABLE_FORMAT));
-
-
-
- ServerSocket svs(port);
- HTTPServer srv(new RotorRequestHandlerFactory(),svs, new HTTPServerParams);
- srv.start();
- waitForTerminationRequest();
- srv.stop();
- }
- return Application::EXIT_OK;
-} \ No newline at end of file
diff --git a/processmodel/rendercontext_src/Makefile b/processmodel/rendercontext_src/Makefile
deleted file mode 100644
index d2546e0..0000000
--- a/processmodel/rendercontext_src/Makefile
+++ /dev/null
@@ -1,252 +0,0 @@
-# The pre-processor and compiler options.
-
-#http://docs.gstreamer.com/display/GstSDK/Installing+on+Linux
-
-#MY_CFLAGS = -fpermissive -std=c++11 -Wno-error -I /opt/gstreamer-sdk/include/gstreamer-0.10/ -I /opt/gstreamer-sdk/include/glib-2.0 -I /opt/gstreamer-sdk/lib/glib-2.0/include -I /opt/gstreamer-sdk/include/libxml2 $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-MY_CFLAGS = -fpermissive -std=c++11
-#-Wno-error $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags)
-
-# -I ../ffmpeg
-
-# The linker options.libgstaasinklibgstaasink.so
-MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil
-#MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --libs)
-# -lgstreamer-0.10 -lgstreamer-video-0.10 -lgstreamer-base-0.10 -lglib-2.0 -lgstapp-0.10
-#MY_LIBS = ../libavcodec/ffmpeg/libavcodec/libavcodec.a ../libavcodec/ffmpeg/libavutil/libavutil.a ../libavcodec/ffmpeg/libavformat/libavformat.a ../libavcodec/ffmpeg/libavfilter/libavfilter.a ../libavcodec/ffmpeg/libavdevice/libavdevice.a -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk
-#GAH! HARD!
-
-# The pre-processor options used by the cpp (man cpp for more).
-CPPFLAGS = -Wall
-
-# The options used in linking as well as in any direct use of ld.
-LDFLAGS =
-
-# The directories in which source files reside.
-# If not specified, only the current directory will be serached.
-SRCDIRS =
-
-# The executable file name.
-# If not specified, current directory name or `a.out' will be used.
-PROGRAM =
-
-## Implicit Section: change the following only when necessary.
-##==========================================================================
-
-# The source file types (headers excluded).
-# .c indicates C source files, and others C++ ones.
-SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
-
-# The header file types.
-HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
-
-# The pre-processor and compiler options.
-# Users can override those variables from the command line.
-CFLAGS = -g -O2
-CXXFLAGS=
-
-# The C program compiler.
-#CC = gcc
-
-# The C++ program compiler.
-#CXX = g++
-
-# Un-comment the following line to compile C programs as C++ ones.
-#CC = $(CXX)
-
-# The command used to delete file.
-RM = rm -f
-
-ETAGS = etags
-ETAGSFLAGS =
-
-CTAGS = ctags
-CTAGSFLAGS =
-
-## Stable Section: usually no need to be changed. But you can add more.
-##==========================================================================
-SHELL = /bin/sh
-EMPTY =
-SPACE = $(EMPTY) $(EMPTY)
-ifeq ($(PROGRAM),)
- CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
- PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
- ifeq ($(PROGRAM),)
- PROGRAM = a.out
- endif
-endif
-ifeq ($(SRCDIRS),)
- SRCDIRS = .
-endif
-SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
-HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
-SRC_CXX = $(filter-out %.c,$(SOURCES))
-OBJS = $(addsuffix .o, $(basename $(SOURCES)))
-DEPS = $(OBJS:.o=.d)
-
-## Define some useful variables.
-DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
- echo "-MM -MP"; else echo "-M"; fi )
-DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
-DEPEND.d = $(subst -g ,,$(DEPEND))
-COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c
-COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
-LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-.PHONY: all objs tags ctags clean distclean help show install
-
-# Delete the default suffixes
-.SUFFIXES:
-
-all: Release
-
-Clang: CXX = clang
-
-Clang: $(PROGRAM)
-
-Release: CXXFLAGS += -O2
-
-Release: $(PROGRAM)
-
-Debug: CXXFLAGS += -g3
-
-Debug: $(PROGRAM)
-
-prefix=/usr/local
-
-Install: rotord
- strip rotord
- install -m 0755 rotord $(prefix)/bin
-
-
-# Rules for creating dependency files (.d).
-#------------------------------------------
-
-%.d:%.c
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.C
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cc
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cpp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.CPP
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.c++
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cp
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-%.d:%.cxx
- @echo -n $(dir $<) > $@
- @$(DEPEND.d) $< >> $@
-
-# Rules for generating object files (.o).
-#----------------------------------------
-objs:$(OBJS)
-
-%.o:%.c
- $(COMPILE.c) $< -o $@
-
-%.o:%.C
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cc
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cpp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.CPP
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.c++
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cp
- $(COMPILE.cxx) $< -o $@
-
-%.o:%.cxx
- $(COMPILE.cxx) $< -o $@
-
-# Rules for generating the tags.
-#-------------------------------------
-tags: $(HEADERS) $(SOURCES)
- $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
-
-ctags: $(HEADERS) $(SOURCES)
- $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
-
-# Rules for generating the executable.
-#-------------------------------------
-$(PROGRAM):$(OBJS)
-ifeq ($(SRC_CXX),) # C program
- $(LINK.c) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-else # C++ program
- $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@
- @echo Type ./$@ to execute the program.
-endif
-
-ifndef NODEP
-ifneq ($(DEPS),)
- sinclude $(DEPS)
-endif
-endif
-
-
-clean:
- $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
-
-distclean: clean
- $(RM) $(DEPS) TAGS
-
-# Show help.
-help:
- @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
- @echo 'Copyright (C) 2007, 2008 whyglinux <whyglinux@hotmail.com>'
- @echo
- @echo 'Usage: make [TARGET]'
- @echo 'TARGETS:'
- @echo ' all (=make) compile and link.'
- @echo ' NODEP=yes make without generating dependencies.'
- @echo ' objs compile only (no linking).'
- @echo ' tags create tags for Emacs editor.'
- @echo ' ctags create ctags for VI editor.'
- @echo ' clean clean objects and the executable file.'
- @echo ' distclean clean objects, the executable and dependencies.'
- @echo ' show show variables (for debug use only).'
- @echo ' help print this message.'
- @echo
- @echo 'Report bugs to <whyglinux AT gmail DOT com>.'
-
-# Show variables (for debug use only.)
-show:
- @echo 'PROGRAM :' $(PROGRAM)
- @echo 'SRCDIRS :' $(SRCDIRS)
- @echo 'HEADERS :' $(HEADERS)
- @echo 'SOURCES :' $(SOURCES)
- @echo 'SRC_CXX :' $(SRC_CXX)
- @echo 'OBJS :' $(OBJS)
- @echo 'DEPS :' $(DEPS)
- @echo 'DEPEND :' $(DEPEND)
- @echo 'COMPILE.c :' $(COMPILE.c)
- @echo 'COMPILE.cxx :' $(COMPILE.cxx)
- @echo 'link.c :' $(LINK.c)
- @echo 'link.cxx :' $(LINK.cxx)
-
-## End of the Makefile ## Suggestions are welcome ## All rights reserved ##
-#############################################################################
diff --git a/processmodel/rendercontext_src/rendercontext.cpp b/processmodel/rendercontext_src/rendercontext.cpp
deleted file mode 100644
index 2f840d5..0000000
--- a/processmodel/rendercontext_src/rendercontext.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "Poco/Net/HTTPServer.h"
-#include "Poco/Net/HTTPRequestHandler.h"
-#include "Poco/Net/HTTPRequestHandlerFactory.h"
-#include "Poco/Net/HTTPServerParams.h"
-#include "Poco/Net/HTTPServerRequest.h"
-#include "Poco/Net/HTTPServerResponse.h"
-#include "Poco/Net/HTTPServerParams.h"
-#include "Poco/Net/ServerSocket.h"
-#include "Poco/Timestamp.h"
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/DateTimeFormat.h"
-#include "Poco/Exception.h"
-#include "Poco/NotificationCenter.h"
-#include "Poco/Util/ServerApplication.h"
-#include "Poco/Util/Option.h"
-#include "Poco/Util/OptionSet.h"
-#include "Poco/Util/HelpFormatter.h"
-#include "Poco/FileStream.h"
-#include "Poco/StreamCopier.h"
-#include "Poco/Net/HTTPStreamFactory.h"
-
-#include "Poco/Process.h"
-#include "Poco/PipeStream.h"
-#include <deque>
-#include <iostream>
-
-int main(int argc, char** argv)
-{
- std::deque<int> work_queue;
- int count=0;
- //while (true){
- // std::cout<<count<<" "<<std::cin;
- // count ++;
- //}
- std::cout<<"hello, world!"<<std::endl; //;
- //printf("hello, world!\n");
- return 0;
-}
-
-int main(int argc, char** argv)
-{
- HTTPStreamFactory::registerFactory();
- RotorServer app;
- return app.run(argc, argv);
-}
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp
index 7c00b91..c21d077 100755
--- a/rotord/src/libavwrapper.cpp
+++ b/rotord/src/libavwrapper.cpp
@@ -223,6 +223,10 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 )
pCtx->time_base.den = 1000;
+ framerate=(((float)container->streams[videoStream]->r_frame_rate.num)/((float)container->streams[videoStream]->r_frame_rate.den));
+
+ //cerr<<"codecContext timebase: "<<(((float)pCtx->time_base.num)/((float)pCtx->time_base.den))<<" videostream framerate: "<<(((float)container->streams[videoStream]->r_frame_rate.num)/((float)container->streams[videoStream]->r_frame_rate.den))<<endl;
+
//cerr<<"stream frame rate:"<<container->streams[videoStream]->r_frame_rate.num<<"/"<<container->streams[videoStream]->r_frame_rate.den<<endl;
//cerr<<"video duration: "<<container->duration<<endl;
@@ -240,8 +244,7 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
if (numFrames<1){
//some codecs don't keep this info in the header
- float fr=((float)container->streams[videoStream]->r_frame_rate.num)/container->streams[videoStream]->r_frame_rate.den;
- numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * fr );
+ numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * framerate );
//this approach still doesn't seem to give quite the right answer- comes out a little too big
//could alternatively just redefine the length if the reader fails
}
diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h
index 4c5cb02..ebe47c1 100755
--- a/rotord/src/libavwrapper.h
+++ b/rotord/src/libavwrapper.h
@@ -29,6 +29,10 @@
//http://blog.tomaka17.com/2012/03/libavcodeclibavformat-tutorial/
//great to use c++11 features
+
+//http://dranger.com/ffmpeg/
+//the mnost up to date tutorial?
+
#ifndef UINT64_C
#define UINT64_C(c) (c ## ULL)
#endif
@@ -103,6 +107,7 @@ namespace libav {
int getNumberOfFrames() const;
int getWidth() const;
int getHeight() const;
+ float getFrameRate() const{return framerate;};
int getNumberOfChannels() const;
bool readNextFrame(int targetFrameIndex = 0);
bool readNextFrameWithPacket(int targetFrameIndex, AVPacket& packet, AVFrame* pYuv);
@@ -116,6 +121,7 @@ namespace libav {
int videoStream;
int previousFrameIndex;
bool isOpen;
+
bool open(std::string& fileName, enum PixelFormat formatParam = PIX_FMT_RGB24);
bool open(char* fileName, enum PixelFormat formatParam = PIX_FMT_RGB24);
@@ -138,6 +144,9 @@ namespace libav {
size_t numBytes;
int numFrames;
int sc; // number of color channels
+ float framerate;
+ //NB representing framerate as a float implies that
+ //ABOVE ~93 HOURS AT 25FPS the calculations will be inaccurate
};
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index f96fbc3..c7e7bc7 100755
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -282,7 +282,7 @@ bool Video_loader::load(const string &_filename){
string uri="file://"+_filename;
isLoaded=player.open(uri);
if (isLoaded){
- logger.information("Video_loader loaded "+filename+": "+ofToString(player.getNumberOfFrames())+" frames, "+ofToString(player.getWidth())+"x"+ofToString(player.getHeight()));
+ logger.information("Video_loader loaded "+filename+": "+ofToString(player.getNumberOfFrames())+" frames, "+ofToString(player.getFrameRate())+" fps, "+ofToString(player.getWidth())+"x"+ofToString(player.getHeight()));
return true;
}
@@ -293,16 +293,26 @@ bool Video_loader::load(const string &_filename){
Image* Video_loader::output(const Frame_spec &frame){
if (isLoaded){
- int wanted=(((int) ((frame.time*frame.framerate)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1?
+ //this approach is running into the inability to seek when requesting playback speed > 1.
+ //need to cache frames so as to avoid asking for a frame other than the next one.
+ //need an algorithm to find the previous keyframe and seek forward
- if (!player.fetchFrame(frame.w,frame.h,wanted)) { //seek fail
- Logger& logger = Logger::get("Rotor");
- logger.error("Video_loader failed to seek frame "+ofToString(wanted)+" of "+filename);
-
- if (image.w>0) return &image; //just return the previous frame if possible
- else return nullptr;
- };
- image.setup_fromRGB(frame.w,frame.h,player.pFrameRGB->data[0],player.pFrameRGB->linesize[0]-(frame.w*3));
+ float clipframerate=(framerate==0.0f?player.getFrameRate():framerate);
+
+ float clipspeed=(clipframerate/frame.framerate)*speed;
+
+ int wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1?
+ if (wanted!=lastframe){
+ if (!player.fetchFrame(frame.w,frame.h,wanted)) { //seek fail
+ Logger& logger = Logger::get("Rotor");
+ logger.error("Video_loader failed to seek frame "+ofToString(wanted)+" of "+filename);
+
+ if (image.w>0) return &image; //just return the previous frame if possible
+ else return nullptr;
+ }
+ image.setup_fromRGB(frame.w,frame.h,player.pFrameRGB->data[0],player.pFrameRGB->linesize[0]-(frame.w*3));
+ lastframe=wanted;
+ }
return &image;
}
return nullptr;
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 85e7ac4..8e37b51 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -1037,6 +1037,8 @@ namespace Rotor {
private:
Image *image; //is an image generator
};
+#define VIDEOFRAMES_still 1
+#define VIDEOFRAMES_blend 2
class Video_loader: public Image_node {
public:
Video_loader(){};
@@ -1044,9 +1046,16 @@ namespace Rotor {
base_settings(settings);
isLoaded=false;
filename=find_setting(settings,"filename","");
+ speed=find_setting(settings,"speed",1.0f);
+ framerate=find_setting(settings,"framerate",0.0f);
+ //0.0f signifies to use the internal framerate
if (filename!="") {
load(find_setting(settings,"media_path","")+filename);
}
+ string frame_op=find_setting(settings,"mode","still");
+ if (frame_op=="still") mode=VIDEOFRAMES_still;
+ if (frame_op=="blend") mode=VIDEOFRAMES_blend;
+ lastframe=0;
};
~Video_loader(){};
bool load(const string &filename);
@@ -1057,6 +1066,10 @@ namespace Rotor {
libav::decoder player;
Image image;
string filename;
+ float speed;
+ float framerate;
+ int mode;
+ int lastframe;
};
/*
class CVideo_loader: public Image_node {
diff --git a/vaa3d_wrapper/libavwrapper.cpp b/vaa3d_wrapper/libavwrapper.cpp
deleted file mode 100755
index dec55f7..0000000
--- a/vaa3d_wrapper/libavwrapper.cpp
+++ /dev/null
@@ -1,739 +0,0 @@
-#include "FFMpegVideo.h"
-
-#ifdef USE_FFMPEG
-
-extern "C"
-{
-#include <libswscale/swscale.h>
-}
-
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QEventLoop>
-#include <QFileInfo>
-#include <QMutexLocker>
-#include <QDebug>
-#include <stdexcept>
-#include <iostream>
-#include <cassert>
-
-using namespace std;
-
-// Translated to C++ by Christopher Bruns May 2012
-// from ffmeg_adapt.c in whisk package by Nathan Clack, Mark Bolstadt, Michael Meeuwisse
-
-//QMutex FFMpegVideo::mutex;
-
-// Avoid link error on some macs
-#ifdef __APPLE__
-extern "C" {
-#include <stdlib.h>
-#include <errno.h>
-// #include "compiler/compiler.h"
-
-/*
- * Darwin doesn't have posix_memalign(), provide a private
- * weak alternative
- */
- /*
-int __weak posix_memalign(void **ptr, size_t align, size_t size)
-{
- if (*ptr)
- return 0;
-
- return ENOMEM;
-}
-*/
-}
-#endif
-
-// Custom read function so FFMPEG does not need to read from a local file by name.
-// But rather from a stream derived from a URL or whatever.
-extern "C" {
-
-/*
-int readFunction(void* opaque, uint8_t* buf, int buf_size)
-{
- QIODevice* stream = (QIODevice*)opaque;
- int numBytes = stream->read((char*)buf, buf_size);
- return numBytes;
-}
-*/
-
-// http://cdry.wordpress.com/2009/09/09/using-custom-io-callbacks-with-ffmpeg/
-int64_t seekFunction(void* opaque, int64_t offset, int whence)
-{
- QIODevice* stream = (QIODevice*)opaque;
- if (stream == NULL)
- return -1;
- else if (whence == AVSEEK_SIZE)
- return -1; // "size of my handle in bytes"
- else if (stream->isSequential())
- return -1; // cannot seek a sequential stream
- else if (whence == SEEK_CUR) { // relative to start of file
- if (! stream->seek(stream->pos() + offset) )
- return -1;
- }
- else if (whence == SEEK_END) { // relative to end of file
- assert(offset < 0);
- if (! stream->seek(stream->size() + offset) )
- return -1;
- }
- else if (whence == SEEK_SET) { // relative to start of file
- if (! stream->seek(offset) )
- return -1;
- }
- else {
- assert(false);
- }
- return stream->pos();
-}
-
-}
-
-
-/////////////////////////////
-// AVPacketWrapper methods //
-/////////////////////////////
-
-class AVPacketWrapper
-{
-public:
- AVPacketWrapper();
- virtual ~AVPacketWrapper();
- void free();
-
- AVPacket packet;
-};
-
-
-AVPacketWrapper::AVPacketWrapper()
-{
- packet.destruct = NULL;
-}
-
-/* virtual */
-AVPacketWrapper::~AVPacketWrapper()
-{
- free();
-}
-
-void AVPacketWrapper::free()
-{
- av_free_packet(&packet);
-}
-
-
-/////////////////////////
-// FFMpegVideo methods //
-/////////////////////////
-
-FFMpegVideo::FFMpegVideo(PixelFormat pixelFormat)
- : isOpen(false)
-{
- initialize();
- format = pixelFormat;
-}
-
-FFMpegVideo::FFMpegVideo(QUrl url, PixelFormat pixelFormat)
- : isOpen(false)
-{
- QMutexLocker lock(&FFMpegVideo::mutex);
- initialize();
- format = pixelFormat;
- isOpen = open(url, pixelFormat);
-}
-
-/* virtual */
-FFMpegVideo::~FFMpegVideo()
-{
- QMutexLocker lock(&FFMpegVideo::mutex);
- if (NULL != Sctx) {
- sws_freeContext(Sctx);
- Sctx = NULL;
- }
- if (NULL != pRaw) {
- av_free(pRaw);
- pRaw = NULL;
- }
- if (NULL != pFrameRGB) {
- av_free(pFrameRGB);
- pFrameRGB = NULL;
- }
- if (NULL != pCtx) {
- avcodec_close(pCtx);
- pCtx = NULL;
- }
- if (NULL != container) {
- avformat_close_input(&container);
- container = NULL;
- }
- if (NULL != buffer) {
- av_free(buffer);
- buffer = NULL;
- }
- if (NULL != blank) {
- av_free(blank);
- blank = NULL;
- }
- /*
- if (NULL != avioContext) {
- av_free(avioContext);
- avioContext = NULL;
- }
- */
- if (reply != NULL) {
- reply->deleteLater();
- reply = NULL;
- }
- // Don't need to free pCodec?
-}
-
-bool FFMpegVideo::open(QUrl url, enum PixelFormat formatParam)
-{
- if (url.isEmpty())
- return false;
-
- // Is the movie source a local file?
- if (url.host() == "localhost")
- url.setHost("");
- QString fileName = url.toLocalFile();
- if ( (! fileName.isEmpty())
- && (QFileInfo(fileName).exists()) )
- {
- // return open(fileName, formatParam); // for testing only
-
- // Yes, the source is a local file
- fileStream.setFileName(fileName);
- // qDebug() << fileName;
- if (! fileStream.open(QIODevice::ReadOnly))
- return false;
- return open(fileStream, fileName, formatParam);
- }
-
- // ...No, the source is not a local file
- if (url.host() == "")
- url.setHost("localhost");
- fileName = url.path();
-
- // http://stackoverflow.com/questions/9604633/reading-a-file-located-in-memory-with-libavformat
- // Load from URL
- QEventLoop loop; // for synchronous url fetch http://stackoverflow.com/questions/5486090/qnetworkreply-wait-for-finished
- QObject::connect(&networkManager, SIGNAL(finished(QNetworkReply*)),
- &loop, SLOT(quit()));
- QNetworkRequest request = QNetworkRequest(url);
- // qDebug() << "networkManager" << __FILE__ << __LINE__;
- reply = networkManager.get(request);
- loop.exec();
- if (reply->error() != QNetworkReply::NoError) {
- // qDebug() << reply->error();
- reply->deleteLater();
- reply = NULL;
- return false;
- }
- QIODevice * stream = reply;
- // Mpeg needs seekable device, so create in-memory buffer if necessary
- if (stream->isSequential()) {
- byteArray = stream->readAll();
- fileBuffer.setBuffer(&byteArray);
- fileBuffer.open(QIODevice::ReadOnly);
- if (! fileBuffer.seek(0))
- return false;
- stream = &fileBuffer;
- assert(! stream->isSequential());
- }
- bool result = open(*stream, fileName, formatParam);
- return result;
-}
-
-bool FFMpegVideo::open(QIODevice& fileStream, QString& fileName, enum PixelFormat formatParam)
-{
- // http://stackoverflow.com/questions/9604633/reading-a-file-located-in-memory-with-libavformat
- // I think AVIOContext is the trick used to redivert the input stream
- ioBuffer = (unsigned char *)av_malloc(ioBufferSize + FF_INPUT_BUFFER_PADDING_SIZE); // can get av_free()ed by libav
- avioContext = avio_alloc_context(ioBuffer, ioBufferSize, 0, (void*)(&fileStream), &readFunction, NULL, &seekFunction);
- container = avformat_alloc_context();
- container->pb = avioContext;
-
- // Open file, check usability
- std::string fileNameStd = fileName.toStdString();
- if (!avtry( avformat_open_input(&container, fileNameStd.c_str(), NULL, NULL), fileNameStd ))
- return false;
- return openUsingInitializedContainer(formatParam);
-}
-
-// file name based method for historical continuity
-bool FFMpegVideo::open(QString& fileName, enum PixelFormat formatParam)
-{
- // Open file, check usability
- std::string fileNameStd = fileName.toStdString();
- if (!avtry( avformat_open_input(&container, fileNameStd.c_str(), NULL, NULL), fileNameStd ))
- return false;
- return openUsingInitializedContainer(formatParam);
-}
-
-
-bool FFMpegVideo::openUsingInitializedContainer(enum PixelFormat formatParam)
-{
- format = formatParam;
- sc = getNumberOfChannels();
-
- if (!avtry( avformat_find_stream_info(container, NULL), "Cannot find stream information." ))
- return false;
- if (!avtry( videoStream=av_find_best_stream(container, AVMEDIA_TYPE_VIDEO, -1, -1, &pCodec, 0), "Cannot find a video stream." ))
- return false;
- pCtx=container->streams[videoStream]->codec;
- width = pCtx->width;
- height = pCtx->height;
- if (!avtry( avcodec_open2(pCtx, pCodec, NULL), "Cannot open video decoder." ))
- return false;
-
- /* Frame rate fix for some codecs */
- if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 )
- pCtx->time_base.den = 1000;
-
- /* Compute the total number of frames in the file */
- /* duration is in microsecs */
- numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5);
-
- /* Get framebuffers */
- if (! (pRaw = avcodec_alloc_frame()) )
- throw std::runtime_error("");
- if (! (pFrameRGB = avcodec_alloc_frame()) )
- throw std::runtime_error("");
-
- /* Create data buffer */
- if (format == PIX_FMT_NONE) {
- numBytes = 0;
- buffer = NULL;
- blank = NULL;
- pFrameRGB = NULL;
- Sctx = NULL;
- }
- else {
- numBytes = avpicture_get_size( format, pCtx->width, pCtx->height ); // RGB24 format
- if (! (buffer = (uint8_t*)av_malloc(numBytes + FF_INPUT_BUFFER_PADDING_SIZE)) ) // RGB24 format
- throw std::runtime_error("");
- if (! (blank = (uint8_t*)av_mallocz(avpicture_get_size(pCtx->pix_fmt,width,height))) ) // native codec format
- throw std::runtime_error("");
-
- /* Init buffers */
- avpicture_fill( (AVPicture * ) pFrameRGB, buffer, format,
- pCtx->width, pCtx->height );
-
- /* Init scale & convert */
- if (! (Sctx=sws_getContext(
- pCtx->width,
- pCtx->height,
- pCtx->pix_fmt,
- width,
- height,
- format,
- SWS_POINT, // fastest?
- NULL,NULL,NULL)) )
- throw std::runtime_error("");
- }
-
- /* Give some info on stderr about the file & stream */
- //dump_format(container, 0, fname, 0);
-
- previousFrameIndex = -1;
- return true;
-}
-
-bool FFMpegVideo::fetchFrame(int targetFrameIndex)
-{
- if ((targetFrameIndex < 0) || (targetFrameIndex > numFrames))
- return false;
- if (targetFrameIndex == (previousFrameIndex + 1)) {
- if (! readNextFrame(targetFrameIndex))
- return false;
- }
- else
- if (seekToFrame(targetFrameIndex) < 0)
- return false;
- previousFrameIndex = targetFrameIndex;
- return true;
-}
-
-// \returns current frame on success, otherwise -1
-int FFMpegVideo::seekToFrame(int targetFrameIndex)
-{
- int64_t duration = container->streams[videoStream]->duration;
- int64_t ts = av_rescale(duration,targetFrameIndex,numFrames);
- int64_t tol = av_rescale(duration,1,2*numFrames);
- if ( (targetFrameIndex < 0) || (targetFrameIndex >= numFrames) ) {
- return -1;
- }
- int result = avformat_seek_file( container, //format context
- videoStream,//stream id
- 0, //min timestamp
- ts, //target timestamp
- ts, //max timestamp
- 0); //AVSEEK_FLAG_ANY),//flags
- if (result < 0)
- return -1;
-
- avcodec_flush_buffers(pCtx);
- if (! readNextFrame(targetFrameIndex))
- return -1;
-
- return targetFrameIndex;
-}
-
-bool FFMpegVideo::readNextFrame(int targetFrameIndex)
-{
- AVPacket packet = {0};
- av_init_packet(&packet);
- bool result = readNextFrameWithPacket(targetFrameIndex, packet, pRaw);
- av_free_packet(&packet);
- return result;
-}
-
-// WARNING this method can raise an exception
-bool FFMpegVideo::readNextFrameWithPacket(int targetFrameIndex, AVPacket& packet, AVFrame* pYuv)
-{
- int finished = 0;
- do {
- finished = 0;
- av_free_packet(&packet);
- int result;
- if (!avtry(av_read_frame( container, &packet ), "Failed to read frame"))
- return false; // !!NOTE: see docs on packet.convergence_duration for proper seeking
- if( packet.stream_index != videoStream ) /* Is it what we're trying to parse? */
- continue;
- if (!avtry(avcodec_decode_video2( pCtx, pYuv, &finished, &packet ), "Failed to decode video"))
- return false;
- // handle odd cases and debug
- if((pCtx->codec_id==CODEC_ID_RAWVIDEO) && !finished)
- {
- avpicture_fill( (AVPicture * ) pYuv, blank, pCtx->pix_fmt,width, height ); // set to blank frame
- finished = 1;
- }
-#if 0 // very useful for debugging
- cout << "Packet - pts:" << (int)packet.pts;
- cout << " dts:" << (int)packet.dts;
- cout << " - flag: " << packet.flags;
- cout << " - finished: " << finished;
- cout << " - Frame pts:" << (int)pYuv->pts;
- cout << " " << (int)pYuv->best_effort_timestamp;
- cout << endl;
- /* printf("Packet - pts:%5d dts:%5d (%5d) - flag: %1d - finished: %3d - Frame pts:%5d %5d\n",
- (int)packet.pts,(int)packet.dts,
- packet.flags,finished,
- (int)pYuv->pts,(int)pYuv->best_effort_timestamp); */
-#endif
- if(!finished) {
- if (packet.pts == AV_NOPTS_VALUE)
- throw std::runtime_error("");
- if (packet.size == 0) // packet.size==0 usually means EOF
- break;
- }
- } while ( (!finished) || (pYuv->best_effort_timestamp < targetFrameIndex));
-
- av_free_packet(&packet);
-
- if (format != PIX_FMT_NONE) {
- sws_scale(Sctx, // sws context
- pYuv->data, // src slice
- pYuv->linesize, // src stride
- 0, // src slice origin y
- pCtx->height, // src slice height
- pFrameRGB->data, // dst
- pFrameRGB->linesize ); // dst stride
- }
-
- previousFrameIndex = targetFrameIndex;
- return true;
-}
-
-uint8_t FFMpegVideo::getPixelIntensity(int x, int y, Channel c) const
-{
- return *(pFrameRGB->data[0] + y * pFrameRGB->linesize[0] + x * sc + c);
-}
-
-int FFMpegVideo::getNumberOfFrames() const { return numFrames; }
-
-int FFMpegVideo::getWidth() const { return width; }
-
-int FFMpegVideo::getHeight() const { return height; }
-
-int FFMpegVideo::getNumberOfChannels() const
-{
- switch(format)
- {
- case PIX_FMT_BGRA:
- return 4;
- break;
- case PIX_FMT_RGB24:
- return 3;
- break;
- case PIX_FMT_GRAY8:
- return 1;
- break;
- default:
- return 0;
- break;
- }
- return 0;
-}
-
-void FFMpegVideo::initialize()
-{
- Sctx = NULL;
- pRaw = NULL;
- pFrameRGB = NULL;
- pCtx = NULL;
- container = NULL;
- buffer = NULL;
- blank = NULL;
- pCodec = NULL;
- format = PIX_FMT_NONE;
- reply = NULL;
- ioBuffer = NULL;
- avioContext = NULL;
- FFMpegVideo::maybeInitFFMpegLib();
-}
-
-void FFMpegVideo::maybeInitFFMpegLib()
-{
- if (FFMpegVideo::b_is_one_time_inited)
- return;
- av_register_all();
- avcodec_register_all();
- avformat_network_init();
- FFMpegVideo::b_is_one_time_inited = true;
-}
-
-bool FFMpegVideo::avtry(int result, const std::string& msg) {
- if ((result < 0) && (result != AVERROR_EOF)) {
- char buf[1024];
- av_strerror(result, buf, sizeof(buf));
- std::string message = std::string("FFMpeg Error: ") + msg + buf;
- qDebug() << QString(message.c_str());
- return false;
- }
- return true;
-}
-
-bool FFMpegVideo::b_is_one_time_inited = false;
-
-
-
-///////////////////////////
-// FFMpegEncoder methods //
-///////////////////////////
-
-
-FFMpegEncoder::FFMpegEncoder(const char * file_name, int width, int height, enum CodecID codec_id)
- : picture_yuv(NULL)
- , picture_rgb(NULL)
- , container(NULL)
-{
- if (0 != (width % 2))
- cerr << "WARNING: Video width is not a multiple of 2" << endl;
- if (0 != (height % 2))
- cerr << "WARNING: Video height is not a multiple of 2" << endl;
-
- FFMpegVideo::maybeInitFFMpegLib();
-
- container = avformat_alloc_context();
- if (NULL == container)
- throw std::runtime_error("Unable to allocate format context");
-
- AVOutputFormat * fmt = av_guess_format(NULL, file_name, NULL);
- if (!fmt)
- fmt = av_guess_format("mpeg", NULL, NULL);
- if (!fmt)
- throw std::runtime_error("Unable to deduce video format");
- container->oformat = fmt;
-
- fmt->video_codec = codec_id;
- // fmt->video_codec = CODEC_ID_H264; // fails to write
-
- AVStream * video_st = avformat_new_stream(container, NULL);
-
- pCtx = video_st->codec;
- pCtx->codec_id = fmt->video_codec;
- pCtx->codec_type = AVMEDIA_TYPE_VIDEO;
- // resolution must be a multiple of two
- pCtx->width = width;
- pCtx->height = height;
-
- // bit_rate determines image quality
- pCtx->bit_rate = width * height * 4; // ?
- // pCtx->qmax = 50; // no effect?
-
- // "high quality" parameters from http://www.cs.ait.ac.th/~on/mplayer/pl/menc-feat-enc-libavcodec.html
- // vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:vme=5:naq:qns=2
- if (false) // does not help
- // if (pCtx->codec_id == CODEC_ID_MPEG4)
- {
- pCtx->mb_decision = 2;
- pCtx->last_predictor_count = 3;
- pCtx->pre_dia_size = 2;
- pCtx->dia_size = 2;
- pCtx->max_b_frames = 2;
- pCtx->b_frame_strategy = 2;
- pCtx->trellis = 2;
- pCtx->compression_level = 2;
- pCtx->global_quality = 300;
- pCtx->pre_me = 2;
- pCtx->mv0_threshold = 1;
- // pCtx->quantizer_noise_shaping = 2; // deprecated
- // TODO
- }
-
- pCtx->time_base = (AVRational){1, 25};
- // pCtx->time_base = (AVRational){1, 10};
- pCtx->gop_size = 12; // emit one intra frame every twelve frames
- // pCtx->max_b_frames = 0;
- pCtx->pix_fmt = PIX_FMT_YUV420P;
- if (fmt->flags & AVFMT_GLOBALHEADER)
- pCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
-
- if (pCtx->codec_id == CODEC_ID_H264)
- {
- // http://stackoverflow.com/questions/3553003/encoding-h-264-with-libavcodec-x264
- pCtx->coder_type = 1; // coder = 1
- pCtx->flags|=CODEC_FLAG_LOOP_FILTER; // flags=+loop
- pCtx->me_cmp|= 1; // cmp=+chroma, where CHROMA = 1
- // pCtx->partitions|=X264_PART_I8X8+X264_PART_I4X4+X264_PART_P8X8+X264_PART_B8X8; // partitions=+parti8x8+parti4x4+partp8x8+partb8x8
- pCtx->me_method=ME_HEX; // me_method=hex
- pCtx->me_subpel_quality = 7; // subq=7
- pCtx->me_range = 16; // me_range=16
- pCtx->gop_size = 250; // g=250
- pCtx->keyint_min = 25; // keyint_min=25
- pCtx->scenechange_threshold = 40; // sc_threshold=40
- pCtx->i_quant_factor = 0.71; // i_qfactor=0.71
- pCtx->b_frame_strategy = 1; // b_strategy=1
- pCtx->qcompress = 0.6; // qcomp=0.6
- pCtx->qmin = 10; // qmin=10
- pCtx->qmax = 51; // qmax=51
- pCtx->max_qdiff = 4; // qdiff=4
- pCtx->max_b_frames = 3; // bf=3
- pCtx->refs = 3; // refs=3
- // pCtx->directpred = 1; // directpred=1
- pCtx->trellis = 1; // trellis=1
- // pCtx->flags2|=CODEC_FLAG2_BPYRAMID+CODEC_FLAG2_MIXED_REFS+CODEC_FLAG2_WPRED+CODEC_FLAG2_8X8DCT+CODEC_FLAG2_FASTPSKIP; // flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
- // pCtx->weighted_p_pred = 2; // wpredp=2
- // libx264-main.ffpreset preset
- // pCtx->flags2|=CODEC_FLAG2_8X8DCT;
- // pCtx->flags2^=CODEC_FLAG2_8X8DCT; // flags2=-dct8x8
- }
-
- AVCodec * codec = avcodec_find_encoder(pCtx->codec_id);
- if (NULL == codec)
- throw std::runtime_error("Unable to find Mpeg4 codec");
- if (codec->pix_fmts)
- pCtx->pix_fmt = codec->pix_fmts[0];
- {
- QMutexLocker lock(&FFMpegVideo::mutex);
- if (avcodec_open2(pCtx, codec, NULL) < 0)
- throw std::runtime_error("Error opening codec");
- }
-
- /* Get framebuffers */
- if (! (picture_yuv = avcodec_alloc_frame()) ) // final frame format
- throw std::runtime_error("");
- if (! (picture_rgb = avcodec_alloc_frame()) ) // rgb version I can understand easily
- throw std::runtime_error("");
- /* the image can be allocated by any means and av_image_alloc() is
- * just the most convenient way if av_malloc() is to be used */
- if ( av_image_alloc(picture_yuv->data, picture_yuv->linesize,
- pCtx->width, pCtx->height, pCtx->pix_fmt, 1) < 0 )
- throw std::runtime_error("Error allocating YUV frame buffer");
- if ( av_image_alloc(picture_rgb->data, picture_rgb->linesize,
- pCtx->width, pCtx->height, PIX_FMT_RGB24, 1) < 0 )
- throw std::runtime_error("Error allocating RGB frame buffer");
-
- /* Init scale & convert */
- if (! (Sctx=sws_getContext(
- width,
- height,
- PIX_FMT_RGB24,
- pCtx->width,
- pCtx->height,
- pCtx->pix_fmt,
- SWS_BICUBIC,NULL,NULL,NULL)) )
- throw std::runtime_error("");
-
- /* open the output file */
- if (!(fmt->flags & AVFMT_NOFILE))
- {
- QMutexLocker lock(&FFMpegVideo::mutex);
- if (avio_open(&container->pb, file_name, AVIO_FLAG_WRITE) < 0)
- throw std::runtime_error("Error opening output video file");
- }
- avformat_write_header(container, NULL);
-}
-
-void FFMpegEncoder::setPixelIntensity(int x, int y, int c, uint8_t value)
-{
- uint8_t * ptr = picture_rgb->data[0] + y * picture_rgb->linesize[0] + x * 3 + c;
- *ptr = value;
-}
-
-void FFMpegEncoder::write_frame()
-{
- // convert from RGB24 to YUV
- sws_scale(Sctx, // sws context
- picture_rgb->data, // src slice
- picture_rgb->linesize, // src stride
- 0, // src slice origin y
- pCtx->height, // src slice height
- picture_yuv->data, // dst
- picture_yuv->linesize ); // dst stride
-
- /* encode the image */
- // use non-deprecated avcodec_encode_video2(...)
- AVPacket packet;
- av_init_packet(&packet);
- packet.data = NULL;
- packet.size = 0;
-
- int got_packet;
- int ret = avcodec_encode_video2(pCtx,
- &packet,
- picture_yuv,
- &got_packet);
- if (ret < 0)
- throw std::runtime_error("Video encoding failed");
- if (got_packet)
- {
- // std::cout << "encoding frame" << std::endl;
- int result = av_write_frame(container, &packet);
- av_destruct_packet(&packet);
- }
-}
-
-/* virtual */
-FFMpegEncoder::~FFMpegEncoder()
-{
- int result = av_write_frame(container, NULL); // flush
- result = av_write_trailer(container);
- {
- QMutexLocker lock(&FFMpegVideo::mutex);
- avio_close(container->pb);
- }
- for (int i = 0; i < container->nb_streams; ++i)
- av_freep(container->streams[i]);
- av_free(container);
- container = NULL;
-
- {
- QMutexLocker lock(&FFMpegVideo::mutex);
- avcodec_close(pCtx);
- }
- av_free(pCtx);
- pCtx = NULL;
- av_free(picture_yuv->data[0]);
- av_free(picture_yuv);
- picture_yuv = NULL;
- av_free(picture_rgb->data[0]);
- av_free(picture_rgb);
- picture_rgb = NULL;
-}
-
-#endif // USE_FFMPEG
-
diff --git a/vaa3d_wrapper/libavwrapper.h b/vaa3d_wrapper/libavwrapper.h
deleted file mode 100755
index 015b05d..0000000
--- a/vaa3d_wrapper/libavwrapper.h
+++ /dev/null
@@ -1,132 +0,0 @@
-#ifndef FFMPEGVIDEO_H
-#define FFMPEGVIDEO_H
-
-/*
- * FFMpegVideo.h
- * May 2012 Christopher Bruns
- * The FFMpegVideo class is a C++ wrapper around the poorly documented
- * libavcodec movie API used by ffmpeg. I made extensive use of Nathan
- * Clack's implemention in the whisk project.
- *
- * The FFMpegVideo.h and FFMpegVideo.cpp files depend only on the libavcodec
- * and allied sets of libraries. To compartmentalize and reduce dependencies
- * I placed the Vaa3d specific use of this class into a separate set of
- * source files: loadV3dFFMpeg.h/cpp
- */
-
-#ifdef USE_FFMPEG
-
-extern "C" {
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libavutil/pixfmt.h>
-#include <libavutil/opt.h>
-#include <libavutil/imgutils.h>
-}
-
-//#include <QFile>
-//#include <QNetworkAccessManager>
-//#include <QMutex>
-//#include <QUrl>
-//#include <QBuffer>
-#include <string>
-#include <stdexcept>
-#include <iostream>
-
-// Translated to C++ by Christopher Bruns May 2012
-// from ffmeg_adapt.c in whisk package by Nathan Clack, Mark Bolstadt, Michael Meeuwisse
-class FFMpegVideo
-{
-public:
- enum Channel {
- RED = 0,
- GRAY = 0,
- GREEN = 1,
- BLUE = 2,
- ALPHA = 3
- };
-
- // Some libavcodec calls are not reentrant
- //static QMutex mutex;
- static void maybeInitFFMpegLib();
-
- FFMpegVideo(PixelFormat pixelFormat=PIX_FMT_RGB24);
- //FFMpegVideo(QUrl url, PixelFormat pixelFormat=PIX_FMT_RGB24);
- virtual ~FFMpegVideo();
- //bool open(QUrl url, enum PixelFormat formatParam = PIX_FMT_RGB24);
- //bool open(QIODevice& fileStream, QString& fileName, enum PixelFormat formatParam = PIX_FMT_RGB24);
- uint8_t getPixelIntensity(int x, int y, Channel c = GRAY) const;
- bool fetchFrame(int targetFrameIndex = 0);
- int getNumberOfFrames() const;
- int getWidth() const;
- int getHeight() const;
- int getNumberOfChannels() const;
- bool readNextFrame(int targetFrameIndex = 0);
- bool readNextFrameWithPacket(int targetFrameIndex, AVPacket& packet, AVFrame* pYuv);
- int seekToFrame(int targetFrameIndex = 0);
-
- // make certain members public, for use by Fast3DTexture class
- AVFrame *pFrameRGB;
- AVFrame *pRaw;
- AVFormatContext *container;
- AVCodecContext *pCtx;
- int videoStream;
- int previousFrameIndex;
- bool isOpen;
-
-protected:
- static bool b_is_one_time_inited;
-
- void initialize();
- bool open(string& fileName, enum PixelFormat formatParam);
- bool openUsingInitializedContainer(enum PixelFormat formatParam);
- static bool avtry(int result, const std::string& msg);
-
- AVCodec *pCodec;
- uint8_t *buffer,
- *blank;
- struct SwsContext *Sctx;
- int width, height;
- PixelFormat format;
- size_t numBytes;
- int numFrames;
- int sc; // number of color channels
-
-/*
- // For loading from URL
- static const int ioBufferSize = 32768;
- unsigned char * ioBuffer;
- QNetworkAccessManager networkManager;
- AVIOContext* avioContext;
- QFile fileStream;
- QNetworkReply* reply;
- QBuffer fileBuffer;
- QByteArray byteArray;
- */
-};
-
-
-// TODO - finish refactoring based on
-// http://svn.gnumonks.org/trunk/21c3-video/ffmpeg/ffmpeg-0.4.9-pre1/output_example.c
-class FFMpegEncoder
-{
-public:
- typedef FFMpegVideo::Channel Channel;
-
- FFMpegEncoder(const char * file_name, int width, int height, enum CodecID codec_id = CODEC_ID_MPEG4);
- virtual ~FFMpegEncoder();
- void setPixelIntensity(int x, int y, int c, uint8_t value);
- void write_frame();
-
-protected:
- AVFormatContext *container;
- AVCodecContext *pCtx;
- AVFrame *picture_yuv;
- AVFrame *picture_rgb;
- struct SwsContext *Sctx;
-};
-
-
-#endif // USE_FFMPEG
-
-#endif // FFMPEGVIDEO_H