summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-15 00:12:58 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-15 00:12:58 +0100
commit66c9be6bdb1361e5681e094a0c8170d268aa9518 (patch)
treee8158842f45380dc182a8d82c88db10dab7781e2
parent66b8c4b9ea2567b52a823084f649f7b27ecee5df (diff)
Remove some old hacks.
-rw-r--r--hacks/ffmpeg/Makefile2
-rw-r--r--hacks/ffmpeg/test.cc176
-rw-r--r--hacks/pretty-c++/Makefile4
-rw-r--r--hacks/pretty-c++/src/film.h22
-rw-r--r--hacks/pretty-c++/src/film_view.cc145
-rw-r--r--hacks/pretty-c++/src/film_view.h37
-rw-r--r--hacks/pretty-c++/src/main.cc11
-rw-r--r--hacks/pretty-c++/src/main_window.cc16
-rw-r--r--hacks/pretty-c++/src/main_window.h11
-rw-r--r--hacks/pretty-c++/src/ratio.cc35
-rw-r--r--hacks/pretty-c++/src/ratio.h17
11 files changed, 0 insertions, 476 deletions
diff --git a/hacks/ffmpeg/Makefile b/hacks/ffmpeg/Makefile
deleted file mode 100644
index 99cfdbcd9..000000000
--- a/hacks/ffmpeg/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-test: test.cc
- g++ -D__STDC_CONSTANT_MACROS -Wall -o test test.cc `pkg-config --cflags --libs libavformat libswscale`
diff --git a/hacks/ffmpeg/test.cc b/hacks/ffmpeg/test.cc
deleted file mode 100644
index 2fcc6b605..000000000
--- a/hacks/ffmpeg/test.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-#include <iostream>
-extern "C" {
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libswscale/swscale.h>
-}
-
-using namespace std;
-
-char const video[] = "./starwars.mpg";//Ghostbusters.avi";
-
-static void
-save_frame (AVFrame *frame, int width, int height, int N)
-{
- char filename[32];
-
- sprintf (filename, "frame%d.ppm", N);
- FILE* file = fopen (filename, "wb");
- if (file == NULL) {
- return;
- }
-
- fprintf (file, "P6\n%d %d\n255\n", width, height);
-
- for (int y = 0; y < height; y++) {
- fwrite (frame->data[0] + y * frame->linesize[0], 1, width * 3, file);
- }
-
- fclose (file);
-}
-
-int
-main (int argc, char* argv[])
-{
- av_register_all ();
-
- AVFormatContext* format_context = NULL;
- if (avformat_open_input (&format_context, video, NULL, NULL) != 0) {
- fprintf (stderr, "avformat_open_input failed.\n");
- return -1;
- }
-
- if (avformat_find_stream_info (format_context, NULL) < 0) {
- fprintf (stderr, "av_find_stream_info failed.\n");
- return -1;
- }
-
- av_dump_format (format_context, 0, video, 0);
-
- int video_stream = -1;
- for (uint32_t i = 0; i < format_context->nb_streams; ++i) {
- if (format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- video_stream = i;
- break;
- }
- }
-
- AVCodecContext* decoder_context = format_context->streams[video_stream]->codec;
-
- AVCodec* decoder = avcodec_find_decoder (decoder_context->codec_id);
- if (decoder == NULL) {
- fprintf (stderr, "avcodec_find_decoder failed.\n");
- return -1;
- }
-
- if (avcodec_open2 (decoder_context, decoder, NULL) < 0) {
- fprintf (stderr, "avcodec_open failed.\n");
- return -1;
- }
-
- /* XXX */
- if (decoder_context->time_base.num > 1000 && decoder_context->time_base.den == 1) {
- decoder_context->time_base.den = 1000;
- }
-
- AVCodec* encoder = avcodec_find_encoder (CODEC_ID_JPEG2000);
- if (encoder == NULL) {
- cerr << "avcodec_find_encoder failed.\n";
- return -1;
- }
-
- AVCodecContext* encoder_context = avcodec_alloc_context3 (encoder);
-
- cout << decoder_context->width << " x " << decoder_context->height << "\n";
- encoder_context->width = decoder_context->width;
- encoder_context->height = decoder_context->height;
- /* XXX */
- encoder_context->time_base = (AVRational) {1, 25};
- encoder_context->pix_fmt = PIX_FMT_YUV420P;
- encoder_context->compression_level = 0;
-
- if (avcodec_open2 (encoder_context, encoder, NULL) < 0) {
- cerr << "avcodec_open failed.\n";
- return -1;
- }
-
- AVFrame* frame = avcodec_alloc_frame ();
-
- AVFrame* frame_RGB = avcodec_alloc_frame ();
- if (frame_RGB == NULL) {
- fprintf (stderr, "avcodec_alloc_frame failed.\n");
- return -1;
- }
-
- FILE* outfile = fopen ("output", "wb");
-
- int num_bytes = avpicture_get_size (PIX_FMT_RGB24, decoder_context->width, decoder_context->height);
- uint8_t* buffer = (uint8_t *) malloc (num_bytes);
-
- avpicture_fill ((AVPicture *) frame_RGB, buffer, PIX_FMT_RGB24, decoder_context->width, decoder_context->height);
-
- /* alloc image and output buffer */
- int outbuf_size = 100000;
- uint8_t* outbuf = (uint8_t *) malloc (outbuf_size);
- int out_size = 0;
-
- AVPacket packet;
- int i = 0;
- while (av_read_frame (format_context, &packet) >= 0) {
-
- int frame_finished;
-
- if (packet.stream_index == video_stream) {
- avcodec_decode_video2 (decoder_context, frame, &frame_finished, &packet);
-
- if (frame_finished) {
- static struct SwsContext *img_convert_context;
-
- if (img_convert_context == NULL) {
- int w = decoder_context->width;
- int h = decoder_context->height;
-
- img_convert_context = sws_getContext (
- w, h,
- decoder_context->pix_fmt,
- w, h, PIX_FMT_RGB24, SWS_BICUBIC,
- NULL, NULL, NULL
- );
-
- if (img_convert_context == NULL) {
- fprintf (stderr, "sws_getContext failed.\n");
- return -1;
- }
- }
-
- sws_scale (
- img_convert_context, frame->data, frame->linesize, 0,
- decoder_context->height, frame_RGB->data, frame_RGB->linesize
- );
-
- out_size = avcodec_encode_video (encoder_context, outbuf, outbuf_size, frame);
- ++i;
- if (i == 200) {
- fwrite (outbuf, 1, out_size, outfile);
- }
- }
- }
-
- av_free_packet (&packet);
- }
-
- while (out_size) {
- out_size = avcodec_encode_video (encoder_context, outbuf, outbuf_size, NULL);
- fwrite (outbuf, 1, out_size, outfile);
- }
-
- fclose (outfile);
- free (buffer);
- av_free (frame_RGB);
- av_free (frame);
- avcodec_close (decoder_context);
- avcodec_close (encoder_context);
- avformat_close_input (&format_context);
-
- return 0;
-}
diff --git a/hacks/pretty-c++/Makefile b/hacks/pretty-c++/Makefile
deleted file mode 100644
index 3eeef0271..000000000
--- a/hacks/pretty-c++/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-SRC := src/main_window.cc src/main.cc
-
-dvdomatic: $(SRC)
- g++ -g -Wall -o $@ $(SRC) `pkg-config --cflags --libs gtkmm-2.4`
diff --git a/hacks/pretty-c++/src/film.h b/hacks/pretty-c++/src/film.h
deleted file mode 100644
index 4361c47db..000000000
--- a/hacks/pretty-c++/src/film.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "ratio.h"
-
-class Film
-{
-public:
-
-private:
- std::string _name;
- std::string _content;
- Ratio _ratio;
- bool _dvd;
- int _dvd_title;
- bool _deinterlace;
- int _left_crop;
- int _right_crop;
- int _top_crop;
- int _bottom_crop;
-
- int _width;
- int _height;
- float _length;
-};
diff --git a/hacks/pretty-c++/src/film_view.cc b/hacks/pretty-c++/src/film_view.cc
deleted file mode 100644
index 988f25f53..000000000
--- a/hacks/pretty-c++/src/film_view.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-FilmView::FilmView ()
- : _film (0)
- , _content_file_radio (_content_group)
- , _content_file_chooser ("Content", Gtk::FILE_CHOOSER_ACTION_OPEN)
- , _content_file_button (_content_file_chooser)
- , _content_folder_radio (_content_group)
- , _content_folder_chooser ("Content", Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)
- , _content_folder_button (_content_folder_chooser)
- , _dvd ("DVD")
- , _deinterlace ("Deinterlace")
-{
- _table = manage (new Gtk::Table);
- table->set_row_spacings (4);
- table->set_col_spacings (12);
- main_vbox->pack_start (*table, false, false);
-
- int n = 0;
-
- table->attach (*left_aligned_label ("Content"), 0, 1, n, n + 1);
- _content_file_chooser.add_button ("Select", Gtk::RESPONSE_OK);
- _content_folder_chooser.add_button ("Select", Gtk::RESPONSE_OK);
- Gtk::HBox* b = Gtk::manage (new Gtk::HBox);
- b->set_spacing (12);
- _content_file_radio.set_label ("File");
- b->pack_start (_content_file_radio, false, false);
- b->pack_start (_content_file_button, true, true);
- _content_folder_radio.set_label ("Folder");
- b->pack_start (_content_folder_radio, false, false);
- b->pack_start (_content_folder_button, true, true);
- table->attach (*b, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Name"), 0, 1, n, n + 1);
- table->attach (_name, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Ratio"), 0, 1, n, n + 1);
- _ratio.append_text ("1.33:1 (4:3)");
- _ratio.append_text ("1.78:1 (16:9)");
- _ratio.append_text ("1.85:1 (Flat)");
- _ratio.append_text ("2.39:1 (Scope)");
- table->attach (_ratio, 1, 2, n, n + 1);
- _ratio.set_active_text ("1.85:1 (Flat)");
- ++n;
-
- table->attach (_dvd, 0, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("DVD title"), 0, 1, n, n + 1);
- _dvd_title.set_range (1, 64);
- _dvd_title.set_increments (1, 4);
- _dvd_title.set_value (1);
- table->attach (_dvd_title, 1, 2, n, n + 1);
- ++n;
-
- table->attach (_deinterlace, 0, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Left Crop"), 0, 1, n, n + 1);
- _left_crop.set_range (0, 1024);
- _left_crop.set_increments (1, 64);
- _left_crop.set_value (0);
- table->attach (_left_crop, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Right Crop"), 0, 1, n, n + 1);
- _right_crop.set_range (0, 1024);
- _right_crop.set_increments (1, 64);
- _right_crop.set_value (0);
- table->attach (_right_crop, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Top Crop"), 0, 1, n, n + 1);
- _top_crop.set_range (0, 1024);
- _top_crop.set_increments (1, 64);
- _top_crop.set_value (0);
- table->attach (_top_crop, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Bottom Crop"), 0, 1, n, n + 1);
- _bottom_crop.set_range (0, 1024);
- _bottom_crop.set_increments (1, 64);
- _bottom_crop.set_value (0);
- table->attach (_bottom_crop, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Size"), 0, 1, n, n + 1);
- table->attach (_size, 1, 2, n, n + 1);
- ++n;
-
- table->attach (*left_aligned_label ("Length"), 0, 1, n, n + 1);
- table->attach (_length, 1, 2, n, n + 1);
- ++n;
-
- /* We only need to connect to one of the radios in the group */
- _content_file_radio.signal_toggled().connect (sigc::mem_fun (*this, &FilmView::content_radio_toggled));
- _content_file_button.signal_file_set().connect (sigc::mem_fun (*this, &FilmView::content_changed));
- _content_folder_button.signal_file_set().connect (sigc::mem_fun (*this, &FilmView::content_changed));
- _dvd.signal_toggled().connect (sigc::mem_fun (*this, &FilmView::update_dvd_title_sensitivity));
-
- update_content_radio_sensitivity ();
- update_dvd_title_sensitivity ();
- show_all ();
-}
-
-Gtk::Label *
-FilmView::left_aligned_label (string const & t) const
-{
- Gtk::Label* l = Gtk::manage (new Gtk::Label (t));
- l->set_alignment (0, 0.5);
- return l;
-}
-
-void
-FilmView::content_radio_toggled ()
-{
- update_content_radio_sensitivity ();
- content_changed ();
-}
-
-void
-FilmView::update_content_radio_sensitivity ()
-{
- _content_file_button.set_sensitive (_content_file_radio.get_active ());
- _content_folder_button.set_sensitive (_content_folder_radio.get_active ());
-}
-
-void
-FilmView::update_dvd_title_sensitivity ()
-{
- _dvd_title.set_sensitive (_dvd.get_active ());
-}
-
-void
-FilmView::content_changed ()
-{
- cout << "Content changed.\n";
-}
-
-void
-FilmView::set_film (Film* f)
-{
- _film = f;
- update ();
-}
diff --git a/hacks/pretty-c++/src/film_view.h b/hacks/pretty-c++/src/film_view.h
deleted file mode 100644
index 93916849b..000000000
--- a/hacks/pretty-c++/src/film_view.h
+++ /dev/null
@@ -1,37 +0,0 @@
-class FilmView
-{
-public:
- FilmView ();
-
- void set_film (Film* f);
-
- Gtk::Widget* widget ();
-
-private:
- Gtk::Label* left_aligned_label (std::string const &) const;
- void content_changed ();
- void content_radio_toggled ();
- void update_content_radio_sensitivity ();
- void update_dvd_title_sensitivity ();
-
- Film* _film;
-
- Gtk::RadioButtonGroup _content_group;
- Gtk::RadioButton _content_file_radio;
- Gtk::FileChooserDialog _content_file_chooser;
- Gtk::FileChooserButton _content_file_button;
- Gtk::RadioButton _content_folder_radio;
- Gtk::FileChooserDialog _content_folder_chooser;
- Gtk::FileChooserButton _content_folder_button;
- Gtk::Entry _name;
- Gtk::ComboBoxText _ratio;
- Gtk::CheckButton _dvd;
- Gtk::CheckButton _deinterlace;
- Gtk::SpinButton _dvd_title;
- Gtk::SpinButton _left_crop;
- Gtk::SpinButton _right_crop;
- Gtk::SpinButton _top_crop;
- Gtk::SpinButton _bottom_crop;
- Gtk::Label _size;
- Gtk::Label _length;
-};
diff --git a/hacks/pretty-c++/src/main.cc b/hacks/pretty-c++/src/main.cc
deleted file mode 100644
index f9d39c14c..000000000
--- a/hacks/pretty-c++/src/main.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "main_window.h"
-
-int main (int argc, char* argv[])
-{
- Gtk::Main kit (argc, argv);
-
- MainWindow window;
- Gtk::Main::run (window);
-
- return 0;
-}
diff --git a/hacks/pretty-c++/src/main_window.cc b/hacks/pretty-c++/src/main_window.cc
deleted file mode 100644
index e6974bca7..000000000
--- a/hacks/pretty-c++/src/main_window.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "main_window.h"
-#include <iostream>
-
-using namespace std;
-
-MainWindow::MainWindow ()
-{
- set_title ("DVD-o-matic");
- maximize ();
-
- Gtk::VBox* main_vbox = manage (new Gtk::VBox);
- main_vbox->set_border_width (12);
- add (*main_vbox);
-
- main_vbox->add (*_film_view.widget ());
-}
diff --git a/hacks/pretty-c++/src/main_window.h b/hacks/pretty-c++/src/main_window.h
deleted file mode 100644
index 63a224827..000000000
--- a/hacks/pretty-c++/src/main_window.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <gtkmm.h>
-#include <string>
-
-class MainWindow : public Gtk::Window
-{
-public:
- MainWindow ();
-
-private:
- FilmView _film_view;
-};
diff --git a/hacks/pretty-c++/src/ratio.cc b/hacks/pretty-c++/src/ratio.cc
deleted file mode 100644
index b1df7fabd..000000000
--- a/hacks/pretty-c++/src/ratio.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <sstream>
-#include "ratio.h"
-
-using namespace std;
-
-Ratio::Ratio ()
- : _ratio (1.85)
-{
-
-}
-
-Ratio::Ratio (float r)
- : _ratio (r)
-{
-
-}
-
-string
-Ratio::name () const
-{
- switch (_ratio) {
- case 1.85:
- return "Flat (1.85:1)";
- break;
- case 2.39:
- return "Scope (2.39:1)";
- break;
- }
-
- stringstream s;
- s << _ratio;
- return s.str ();
-}
-
-
diff --git a/hacks/pretty-c++/src/ratio.h b/hacks/pretty-c++/src/ratio.h
deleted file mode 100644
index a08999fa4..000000000
--- a/hacks/pretty-c++/src/ratio.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <string>
-
-class Ratio
-{
-public:
- Ratio ();
- Ratio (float);
-
- float ratio () const {
- return _ratio;
- }
-
- std::string name () const;
-
-private:
- float _ratio;
-};