Remove the dependency of pixfmt.h in ffms.h
Added the alternative FFMS_GetPixFmt() for getting the different pixel format values

Originally committed to SVN as r2845.
This commit is contained in:
Fredrik Mellbin 2009-04-24 19:56:19 +00:00
parent aaad6b4ad6
commit 6fae2955fd
6 changed files with 44 additions and 34 deletions

View File

@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#include <libavutil/pixfmt.h>
#include "ffavisynth.h" #include "ffavisynth.h"
#include "utils.h" #include "utils.h"
@ -74,9 +75,9 @@ AvisynthVideoSource::~AvisynthVideoSource() {
FFMS_DestroyVideoSource(VS); FFMS_DestroyVideoSource(VS);
} }
void AvisynthVideoSource::InitOutputFormat(PixelFormat CurrentFormat, IScriptEnvironment *Env) { void AvisynthVideoSource::InitOutputFormat(enum PixelFormat CurrentFormat, IScriptEnvironment *Env) {
int Loss; int Loss;
PixelFormat BestFormat = avcodec_find_best_pix_fmt((1 << PIX_FMT_YUVJ420P) | (1 << PIX_FMT_YUV420P) | (1 << PIX_FMT_YUYV422) | (1 << PIX_FMT_RGB32) | (1 << PIX_FMT_BGR24), CurrentFormat, 1 /* Required to prevent pointless RGB32 => RGB24 conversion */, &Loss); enum PixelFormat BestFormat = avcodec_find_best_pix_fmt((1 << PIX_FMT_YUVJ420P) | (1 << PIX_FMT_YUV420P) | (1 << PIX_FMT_YUYV422) | (1 << PIX_FMT_RGB32) | (1 << PIX_FMT_BGR24), CurrentFormat, 1 /* Required to prevent pointless RGB32 => RGB24 conversion */, &Loss);
switch (BestFormat) { switch (BestFormat) {
case PIX_FMT_YUVJ420P: // stupid yv12 distinctions, also inexplicably completely undeniably incompatible with all other supported output formats case PIX_FMT_YUVJ420P: // stupid yv12 distinctions, also inexplicably completely undeniably incompatible with all other supported output formats

View File

@ -41,7 +41,7 @@ private:
int FPSNum; int FPSNum;
int FPSDen; int FPSDen;
void InitOutputFormat(PixelFormat CurrentFormat, IScriptEnvironment *Env); void InitOutputFormat(enum PixelFormat CurrentFormat, IScriptEnvironment *Env);
PVideoFrame OutputFrame(const AVFrameLite *SrcPicture, IScriptEnvironment *Env); PVideoFrame OutputFrame(const AVFrameLite *SrcPicture, IScriptEnvironment *Env);
public: public:
AvisynthVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, int FPSNum, int FPSDen, const char *PP, int Threads, int SeekMode, IScriptEnvironment* Env, char *ErrorMsg, unsigned MsgSize); AvisynthVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, int FPSNum, int FPSDen, const char *PP, int Threads, int SeekMode, IScriptEnvironment* Env, char *ErrorMsg, unsigned MsgSize);

View File

@ -18,6 +18,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
extern "C" {
#include <libavcodec/avcodec.h>
}
#include "ffms.h" #include "ffms.h"
#include "ffvideosource.h" #include "ffvideosource.h"
#include "ffaudiosource.h" #include "ffaudiosource.h"
@ -205,3 +209,6 @@ FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, c
return WriteIndex(IndexFile, TrackIndices, ErrorMsg, MsgSize); return WriteIndex(IndexFile, TrackIndices, ErrorMsg, MsgSize);
} }
FFMS_API(enum PixelFormat) FFMS_GetPixFmt(const char *Name) {
return avcodec_get_pix_fmt(Name);
}

View File

@ -22,7 +22,6 @@
#define FFMS_H #define FFMS_H
#include <stdint.h> #include <stdint.h>
#include <libavutil/pixfmt.h>
#ifdef __cplusplus #ifdef __cplusplus
# define EXTERN_C extern "C" # define EXTERN_C extern "C"
@ -49,6 +48,8 @@ class FrameInfoVector;
typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private); typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private);
enum PixelFormat;
enum FFMS_SeekMode { enum FFMS_SeekMode {
FFMS_SEEK_LINEAR_NO_RW = -1, FFMS_SEEK_LINEAR_NO_RW = -1,
FFMS_SEEK_LINEAR = 0, FFMS_SEEK_LINEAR = 0,
@ -98,7 +99,7 @@ struct VideoProperties {
int FPSDenominator; int FPSDenominator;
int FPSNumerator; int FPSNumerator;
int NumFrames; int NumFrames;
PixelFormat VPixelFormat; enum PixelFormat VPixelFormat;
int SARNum; int SARNum;
int SARDen; int SARDen;
int CropTop; int CropTop;
@ -147,5 +148,5 @@ FFMS_API(int) FFMS_WriteTimecodes(FrameInfoVector *FIV, const char *TimecodeFile
FFMS_API(FrameIndex *) FFMS_MakeIndex(const char *SourceFile, int IndexMask, int DumpMask, const char *AudioFile, bool IgnoreDecodeErrors, IndexCallback IP, void *Private, char *ErrorMsg, unsigned MsgSize); FFMS_API(FrameIndex *) FFMS_MakeIndex(const char *SourceFile, int IndexMask, int DumpMask, const char *AudioFile, bool IgnoreDecodeErrors, IndexCallback IP, void *Private, char *ErrorMsg, unsigned MsgSize);
FFMS_API(FrameIndex *) FFMS_ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize); FFMS_API(FrameIndex *) FFMS_ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize); FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
FFMS_API(PixelFormat) FFMS_GetPixFmt(const char *Name);
#endif #endif

View File

@ -234,6 +234,7 @@ Note that --enable-w32threads is required for multithreaded decoding to work.
<h2>Changes</h2> <h2>Changes</h2>
<ul> <ul>
<li>2.00 beta 7<ul> <li>2.00 beta 7<ul>
<li>Using ffms2 as a library no longer requires an installed pixfmt.h from libavutil, it is however still required to compile ffms2 and the avisynth plugin part</li>
<li>Fix a crash bug at the end of files with b-frames in beta 6 caused by uninitialized null packets</li> <li>Fix a crash bug at the end of files with b-frames in beta 6 caused by uninitialized null packets</li>
<li>Includes TheFluff's wrapper function for 1.21 style syntax</li> <li>Includes TheFluff's wrapper function for 1.21 style syntax</li>
<li>Added a simple regression test application to the source</li> <li>Added a simple regression test application to the source</li>

View File

@ -28,7 +28,7 @@ extern "C" {
using namespace std; using namespace std;
//#define VERBOSE #define VERBOSE
static int FFMS_CC UpdateProgress(int State, int64_t Current, int64_t Total, void *Private) { static int FFMS_CC UpdateProgress(int State, int64_t Current, int64_t Total, void *Private) {
@ -59,7 +59,11 @@ int main(int argc, char *argv[]) {
#ifndef VERBOSE #ifndef VERBOSE
FFMS_NoLog(); FFMS_NoLog();
#endif #endif
enum PixelFormat FMT_YV12A = FFMS_GetPixFmt("PIX_FMT_YUV420P)");
enum PixelFormat FMT_YV12B = FFMS_GetPixFmt("PIX_FMT_YUVJ420P");
enum PixelFormat FMT_YUY2 = FFMS_GetPixFmt("PIX_FMT_YUV422P");
av_md5_init(ctx); av_md5_init(ctx);
FrameIndex *FI = FFMS_MakeIndex(argv[1], -1, 0, NULL, false, UpdateProgress, argv[1], ErrorMsg, sizeof(ErrorMsg)); FrameIndex *FI = FFMS_MakeIndex(argv[1], -1, 0, NULL, false, UpdateProgress, argv[1], ErrorMsg, sizeof(ErrorMsg));
if (!FI) { if (!FI) {
@ -103,32 +107,28 @@ int main(int argc, char *argv[]) {
Data[1] = AVF->Data[1]; Data[1] = AVF->Data[1];
Data[2] = AVF->Data[2]; Data[2] = AVF->Data[2];
switch (VP->VPixelFormat) { if (VP->VPixelFormat == FMT_YV12A || VP->VPixelFormat == FMT_YV12B) {
case PIX_FMT_YUV420P: for (int j = 0; j < VP->Height / 2; j++) {
case PIX_FMT_YUVJ420P: av_md5_update(ctx, Data[0], VP->Width);
for (int j = 0; j < VP->Height / 2; j++) { Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[0], VP->Width); av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0]; Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[0], VP->Width); av_md5_update(ctx, Data[1], VP->Width / 2);
Data[0] += AVF->Linesize[0]; Data[1] += AVF->Linesize[1];
av_md5_update(ctx, Data[1], VP->Width / 2); av_md5_update(ctx, Data[2], VP->Width / 2);
Data[1] += AVF->Linesize[1]; Data[2] += AVF->Linesize[2];
av_md5_update(ctx, Data[2], VP->Width / 2); }
Data[2] += AVF->Linesize[2]; } else if (VP->VPixelFormat == FMT_YUY2) {
} for (int j = 0; j < VP->Height / 2; j++) {
break; av_md5_update(ctx, Data[0], VP->Width);
case PIX_FMT_YUV422P: Data[0] += AVF->Linesize[0];
for (int j = 0; j < VP->Height / 2; j++) { av_md5_update(ctx, Data[0], VP->Width);
av_md5_update(ctx, Data[0], VP->Width); Data[0] += AVF->Linesize[0];
Data[0] += AVF->Linesize[0]; av_md5_update(ctx, Data[1], VP->Width / 2);
av_md5_update(ctx, Data[0], VP->Width); Data[1] += AVF->Linesize[1];
Data[0] += AVF->Linesize[0]; av_md5_update(ctx, Data[2], VP->Width / 2);
av_md5_update(ctx, Data[1], VP->Width / 2); Data[2] += AVF->Linesize[2];
Data[1] += AVF->Linesize[1]; }
av_md5_update(ctx, Data[2], VP->Width / 2);
Data[2] += AVF->Linesize[2];
}
break;
} }
} }