2006-02-24 03:54:30 +01:00
|
|
|
// Copyright (c) 2006, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// AEGISUB
|
|
|
|
//
|
|
|
|
// Website: http://aegisub.cellosoft.com
|
|
|
|
// Contact: mailto:zeratul@cellosoft.com
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
2006-02-24 09:30:08 +01:00
|
|
|
///////////////////////////////////
|
|
|
|
// Auto-enable LAVC on non-windows
|
|
|
|
#ifndef __WINDOWS__
|
|
|
|
#ifndef USE_LAVC
|
|
|
|
#define USE_LAVC
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-02-24 03:54:30 +01:00
|
|
|
///////////
|
|
|
|
// Headers
|
|
|
|
#ifdef USE_LAVC
|
2006-02-24 04:54:40 +01:00
|
|
|
#define EMULATE_INTTYPES
|
2006-02-24 06:58:45 +01:00
|
|
|
#include <ffmpeg/avcodec.h>
|
|
|
|
#include <ffmpeg/avformat.h>
|
2006-02-24 03:54:30 +01:00
|
|
|
#include "video_provider.h"
|
2006-03-01 04:17:31 +01:00
|
|
|
#include "mkv_wrap.h"
|
2006-04-15 00:35:02 +02:00
|
|
|
#include "lavc_file.h"
|
2006-02-24 03:54:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
// LibAVCodec provider
|
|
|
|
class LAVCVideoProvider : public VideoProvider {
|
2006-04-15 00:37:05 +02:00
|
|
|
friend class LAVCAudioProvider;
|
2006-02-24 04:54:40 +01:00
|
|
|
private:
|
2006-03-01 04:17:31 +01:00
|
|
|
MatroskaWrapper mkv;
|
|
|
|
|
2006-04-15 00:35:02 +02:00
|
|
|
LAVCFile *lavcfile;
|
2006-02-24 04:54:40 +01:00
|
|
|
AVCodecContext *codecContext;
|
|
|
|
AVStream *stream;
|
|
|
|
AVCodec *codec;
|
2006-02-24 06:24:08 +01:00
|
|
|
AVFrame *frame;
|
2006-02-24 04:54:40 +01:00
|
|
|
int vidStream;
|
|
|
|
|
2006-02-24 08:27:42 +01:00
|
|
|
double zoom;
|
|
|
|
double dar;
|
|
|
|
int display_w;
|
|
|
|
int display_h;
|
|
|
|
|
2006-02-25 21:48:32 +01:00
|
|
|
wxArrayInt bytePos;
|
|
|
|
|
2006-03-01 04:17:31 +01:00
|
|
|
bool isMkv;
|
2006-02-24 07:34:35 +01:00
|
|
|
__int64 lastDecodeTime;
|
2006-02-24 06:58:45 +01:00
|
|
|
int frameNumber;
|
2006-02-25 21:48:32 +01:00
|
|
|
int length;
|
2006-02-24 06:58:45 +01:00
|
|
|
wxBitmap curFrame;
|
2006-02-24 08:27:42 +01:00
|
|
|
bool validFrame;
|
2006-02-24 06:58:45 +01:00
|
|
|
|
2006-02-24 08:27:42 +01:00
|
|
|
uint8_t *buffer1;
|
|
|
|
uint8_t *buffer2;
|
|
|
|
int buffer1Size;
|
|
|
|
int buffer2Size;
|
2006-02-24 06:24:08 +01:00
|
|
|
|
2006-02-24 08:27:42 +01:00
|
|
|
void UpdateDisplaySize();
|
2006-02-25 03:27:40 +01:00
|
|
|
bool GetNextFrame();
|
2006-02-24 04:54:40 +01:00
|
|
|
void LoadVideo(wxString filename);
|
|
|
|
void Close();
|
2006-05-06 03:06:22 +02:00
|
|
|
wxBitmap AVFrameToWX(AVFrame *frame, int n);
|
|
|
|
|
|
|
|
SubtitleProvider::Overlay *overlay;
|
|
|
|
protected:
|
|
|
|
virtual void AttachOverlay(SubtitleProvider::Overlay *_overlay);
|
2006-02-24 04:54:40 +01:00
|
|
|
|
2006-02-24 03:54:30 +01:00
|
|
|
public:
|
2006-02-24 09:43:44 +01:00
|
|
|
LAVCVideoProvider(wxString filename, wxString subfilename);
|
2006-02-24 03:54:30 +01:00
|
|
|
~LAVCVideoProvider();
|
|
|
|
|
|
|
|
void RefreshSubtitles();
|
|
|
|
|
|
|
|
wxBitmap GetFrame(int n);
|
|
|
|
void GetFloatFrame(float* Buffer, int n);
|
|
|
|
|
|
|
|
int GetPosition();
|
|
|
|
int GetFrameCount();
|
|
|
|
double GetFPS();
|
|
|
|
|
|
|
|
void SetDAR(double dar);
|
|
|
|
void SetZoom(double zoom);
|
|
|
|
int GetWidth();
|
|
|
|
int GetHeight();
|
|
|
|
double GetZoom();
|
|
|
|
|
|
|
|
int GetSourceWidth();
|
|
|
|
int GetSourceHeight();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|