From 39a67529faf2addab2ffb5d479520f44475a457e Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 20 Jun 2014 15:05:24 -0500 Subject: [PATCH] Removed partially implemented SDL player. --- include/OpenShot.h | 1 - include/SDLPlayer.h | 94 --------------- src/CMakeLists.txt | 10 -- src/Main.cpp | 7 -- src/SDLPlayer.cpp | 214 --------------------------------- src/bindings/python/openshot.i | 2 - src/bindings/ruby/openshot.i | 2 - tests/CMakeLists.txt | 9 +- 8 files changed, 1 insertion(+), 338 deletions(-) delete mode 100644 include/SDLPlayer.h delete mode 100644 src/SDLPlayer.cpp diff --git a/include/OpenShot.h b/include/OpenShot.h index 782d6567..3c4245e2 100644 --- a/include/OpenShot.h +++ b/include/OpenShot.h @@ -139,7 +139,6 @@ #include "PlayerBase.h" #include "Point.h" #include "Profiles.h" -#include "SDLPlayer.h" #include "Sleep.h" #include "TextReader.h" #include "Timeline.h" diff --git a/include/SDLPlayer.h b/include/SDLPlayer.h deleted file mode 100644 index 8e579059..00000000 --- a/include/SDLPlayer.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @file - * @brief Header file for SDLPlayer class - * @author Jonathan Thomas - * - * @section LICENSE - * - * Copyright (c) 2008-2014 OpenShot Studios, LLC - * . This file is part of - * OpenShot Library (libopenshot), an open-source project dedicated to - * delivering high quality video editing and animation solutions to the - * world. For more information visit . - * - * OpenShot Library (libopenshot) is free software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * OpenShot Library (libopenshot) 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with OpenShot Library. If not, see . - * - * Also, if your software can interact with users remotely through a computer - * network, you should also make sure that it provides a way for users to - * get its source. For example, if your program is a web application, its - * interface could display a "Source" link that leads users to an archive - * of the code. There are many ways you could offer source, and different - * solutions will be better for different programs; see section 13 for the - * specific requirements. - * - * You should also get your employer (if you work as a programmer) or school, - * if any, to sign a "copyright disclaimer" for the program, if necessary. - * For more information on this, and how to apply and follow the GNU AGPL, see - * . - */ - -#ifndef OPENSHOT_SDL_PLAYER_H -#define OPENSHOT_SDL_PLAYER_H - -#include -#include -#include "../include/PlayerBase.h" -#include "../include/ReaderBase.h" - -#define _SDL_main_h // This prevents SDL_main from replacing our main() function. -#include -#include - -using namespace std; - -namespace openshot -{ - /** - * @brief Player to display a video using SDL (Simple DirectMedia Layer) - * - * This player uses the SDL (Simple DirectMedia Layer) library to display the video. It uses - * an image overlay with YUV420 colorspace, and draws the video to any X11 window you specify. - */ - class SDLPlayer : public PlayerBase - { - private: - int position; ///< Current frame number being played - - public: - /// Default constructor - SDLPlayer(); - - /// Play the video - void Play(); - - /// Display a loading animation - void Loading(); - - /// Pause the video - void Pause(); - - /// Get the current frame number being played - int Position(); - - /// Seek to a specific frame in the player - void Seek(int new_frame); - - /// Stop the video player and clear the cached frames - void Stop(); - - }; - -} - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72c6c33e..57cccd78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,14 +59,6 @@ FIND_PACKAGE(OpenShotAudio REQUIRED) # Include Juce headers (needed for compile) include_directories(${LIBOPENSHOT_AUDIO_INCLUDE_DIRS}) -################# SDL ################### -# Find SDL libraries -SET(SDL_BUILDING_LIBRARY "True") # This prevents SDL_main from being linked -FIND_PACKAGE(SDL REQUIRED) - -# Include SDL headers (needed for compile) -include_directories(${SDL_INCLUDE_DIR}) - ################# QT5 ################### # As moc files are generated in the binary dir, tell CMake # to always look for includes there: @@ -178,7 +170,6 @@ SET ( OPENSHOT_SOURCE_FILES PlayerBase.cpp Point.cpp Profiles.cpp - SDLPlayer.cpp QtPlayer.cpp TextReader.cpp Timeline.cpp @@ -217,7 +208,6 @@ SET ( REQUIRED_LIBRARIES ${ImageMagick_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBOPENSHOT_AUDIO_LIBRARIES} - ${SDL_LIBRARY} ${QT_LIBRARIES} ${PROFILER} ) diff --git a/src/Main.cpp b/src/Main.cpp index 0a3f779e..af3cb2c4 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -127,13 +127,6 @@ int main(int argc, char* argv[]) */ -// SDLPlayer p; -// p.Reader(&r2); -// p.Play(); -// return 0; - - - // Image of interlaced frame // ImageReader ir("/home/jonathan/apps/libopenshot/src/examples/interlaced.png"); // ir.Open(); diff --git a/src/SDLPlayer.cpp b/src/SDLPlayer.cpp deleted file mode 100644 index 5b5f42ca..00000000 --- a/src/SDLPlayer.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @file - * @brief Source file for SDLPlayer class - * @author Jonathan Thomas - * - * @section LICENSE - * - * Copyright (c) 2008-2014 OpenShot Studios, LLC - * . This file is part of - * OpenShot Library (libopenshot), an open-source project dedicated to - * delivering high quality video editing and animation solutions to the - * world. For more information visit . - * - * OpenShot Library (libopenshot) is free software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * OpenShot Library (libopenshot) 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with OpenShot Library. If not, see . - * - * Also, if your software can interact with users remotely through a computer - * network, you should also make sure that it provides a way for users to - * get its source. For example, if your program is a web application, its - * interface could display a "Source" link that leads users to an archive - * of the code. There are many ways you could offer source, and different - * solutions will be better for different programs; see section 13 for the - * specific requirements. - * - * You should also get your employer (if you work as a programmer) or school, - * if any, to sign a "copyright disclaimer" for the program, if necessary. - * For more information on this, and how to apply and follow the GNU AGPL, see - * . - */ - -#include "../include/SDLPlayer.h" - -using namespace openshot; - -// Default constructor -SDLPlayer::SDLPlayer() { - -}; - -// Display a loading animation -void SDLPlayer::Loading() { - mode = PLAYBACK_LOADING; -} - -// Pause the video -void SDLPlayer::Pause() { - mode = PLAYBACK_PAUSED; -} - -// Stop the video player and clear the cached frames -void SDLPlayer::Stop() { - mode = PLAYBACK_STOPPED; -} - -/// Get the current frame number being played -int SDLPlayer::Position() { - return position; -} - -/// Seek to a specific frame in the player -void SDLPlayer::Seek(int new_frame) { - position = new_frame; -} - -// Play the video -void SDLPlayer::Play() -{ - // Set mode - mode = PLAYBACK_PLAY; - - // Init SDL - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) { - fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError()); - exit(1); - } - - // Create an SDL surface - SDL_Surface *screen; - screen = SDL_SetVideoMode(reader->info.width, reader->info.height, 0, SDL_HWSURFACE | SDL_ANYFORMAT | SDL_DOUBLEBUF); - if (!screen) { - fprintf(stderr, "SDL: could not set video mode - exiting\n"); - exit(1); - } - - vector overlays; - int number_of_cycles = 60; - - - // Create YUV Overlay - SDL_Overlay *bmp; - bmp = SDL_CreateYUVOverlay(reader->info.width, reader->info.height, SDL_YV12_OVERLAY, screen); - - cout << setprecision(6); - cout << "START PREPARING SURFACES..." << endl; - - for (int stuff = 0; stuff < number_of_cycles; stuff++) - { - // Get pointer to pixels of image. - tr1::shared_ptr f = reader->GetFrame(300 + stuff); - - // Create YUV Overlay - SDL_Overlay *bmp; - bmp = SDL_CreateYUVOverlay(reader->info.width, reader->info.height, SDL_YV12_OVERLAY, screen); - SDL_LockYUVOverlay(bmp); - - // Get luminance of each pixel - int pixel_index = 0; - int biggest_y = 0; - int smallest_y = 512; - for (int row = 0; row < screen->h; row++) { - // Get array of pixels for this row - //cout << "row: " << row << endl; - const Magick::PixelPacket *imagepixels = f->GetPixels(row); - - // Loop through pixels on this row - for (int column = 0; column < screen->w; column++) { - - // Get a pixel from this row - const Magick::PixelPacket *pixel = imagepixels; - - // Get the RGB colors - float r = pixel[column].red / 255.0; - float b = pixel[column].blue / 255.0; - float g = pixel[column].green / 255.0; - - // Calculate the Y value (brightness or luminance) - float y = (0.299 * r) + (0.587 * g) + (0.114 * b); - - // Update the Y value for every pixel - bmp->pixels[0][pixel_index] = y; - - // Increment counter - pixel_index++; - - } - } - - // Get pixels for resized frame (for reduced color needed by YUV420p) - int divider = 2; - tr1::shared_ptr reduced_color = tr1::shared_ptr(new Magick::Image(*f->GetImage().get())); // copy frame image - Magick::Geometry new_size; - new_size.width(reader->info.width / divider); - new_size.height(reader->info.height / divider); - reduced_color->scale(new_size); - - int number_of_colors = (reader->info.width / divider) * (reader->info.height / divider); - - // Loop through the UV (color info) - for (int pixel_index = 0; pixel_index < number_of_colors; pixel_index++) - { - // Get a pixel from this row - const Magick::PixelPacket *pixel = reduced_color->getConstPixels(0,0, new_size.width(), new_size.height()); - - // Get the RGB colors - float r = pixel[pixel_index].red / 255.0; - float b = pixel[pixel_index].blue / 255.0; - float g = pixel[pixel_index].green / 255.0; - - // Calculate UV colors - float v = (0.439 * r) - (0.368 * g) - (0.071 * b) + 128; - float u = (-0.148 * r) - (0.291 * g) + (0.439 * b) + 128; - - // Update the UV values for every pixel - bmp->pixels[1][pixel_index] = v * 1.0; - bmp->pixels[2][pixel_index] = u * 1.0; - - } - SDL_UnlockYUVOverlay(bmp); - - // Add to vector - overlays.push_back(bmp); - } - - cout << "START DISPLAYING SURFACES..." << endl; - - SDL_Rect rect; - rect.x = 0; - rect.y = 0; - rect.w = reader->info.width; - rect.h = reader->info.height; - - // Loop through overlays and display them - for (int repeat = 0; repeat < 3; repeat++) - { - cout << "START OVERLAY LOOP:" << endl; - for (int z = 0; z < number_of_cycles; z++) - { - cout << z << endl; - //SDL_LockSurface( screen); - //primary_screen->pixels = surfaces[z].pixels; - //SDL_UnlockSurface(primary_screen); - //SDL_UpdateRect(screen, 0, 0, reader->info.width, reader->info.height); - - SDL_DisplayYUVOverlay(overlays[z], &rect); - //SDL_UnlockSurface( screen); - - SDL_Delay(41); - } - } - - cout << "DONE!" << endl; - SDL_Delay(1000); -} - diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index 3c02bf31..1adcd330 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -89,7 +89,6 @@ #include "../../../include/QtPlayer.h" #include "../../../include/KeyFrame.h" #include "../../../include/RendererBase.h" -#include "../../../include/SDLPlayer.h" #include "../../../include/TextReader.h" #include "../../../include/Timeline.h" @@ -132,7 +131,6 @@ %include "../../../include/QtPlayer.h" %include "../../../include/KeyFrame.h" %include "../../../include/RendererBase.h" -%include "../../../include/SDLPlayer.h" %include "../../../include/TextReader.h" %include "../../../include/Timeline.h" diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index 66ad22a6..e6b0c07e 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -95,7 +95,6 @@ namespace tr1 #include "../../../include/QtPlayer.h" #include "../../../include/KeyFrame.h" #include "../../../include/RendererBase.h" -#include "../../../include/SDLPlayer.h" #include "../../../include/TextReader.h" #include "../../../include/Timeline.h" @@ -138,7 +137,6 @@ namespace tr1 %include "../../../include/QtPlayer.h" %include "../../../include/KeyFrame.h" %include "../../../include/RendererBase.h" -%include "../../../include/SDLPlayer.h" %include "../../../include/TextReader.h" %include "../../../include/Timeline.h" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2ae1294c..57ab49e0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -66,13 +66,6 @@ FIND_PACKAGE(OpenShotAudio REQUIRED) # Include Juce headers (needed for compile) include_directories(${LIBOPENSHOT_AUDIO_INCLUDE_DIRS}) -################# SDL ################### -# Find SDL libraries -FIND_PACKAGE(SDL REQUIRED) - -# Include SDL headers (needed for compile) -include_directories(${SDL_INCLUDE_DIR}) - ################# QT5 ################### set(CMAKE_AUTOMOC ON) @@ -111,7 +104,7 @@ IF (ENABLE_BLACKMAGIC) FIND_PACKAGE(BlackMagic) IF (BLACKMAGIC_FOUND) - # Include SDL headers (needed for compile) + # Include Blackmagic headers (needed for compile) include_directories(${BLACKMAGIC_INCLUDE_DIR}) ENDIF (BLACKMAGIC_FOUND) ENDIF (ENABLE_BLACKMAGIC)