Remove old contribs
This commit is contained in:
1 parent
5eba10bd6b
commit
fa1043c984
138 files changed
-27733
No files matched your search
@@ -1,33 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: apitypes.h
|
||||
// Description: Types used in both the API and internally
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Mar 03 09:22:53 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_API_APITYPES_H__
|
||||
#define TESSERACT_API_APITYPES_H__
|
||||
|
||||
#include "publictypes.h"
|
||||
|
||||
// The types used by the API and Page/ResultIterator can be found in:
|
||||
// ccstruct/publictypes.h
|
||||
// ccmain/resultiterator.h
|
||||
// ccmain/pageiterator.h
|
||||
// API interfaces and API users should be sure to include this file, rather
|
||||
// than the lower-level one, and lower-level code should be sure to include
|
||||
// only the lower-level file.
|
||||
|
||||
#endif // TESSERACT_API_APITYPES_H__
|
||||
@@ -1,793 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: baseapi.h
|
||||
// Description: Simple API for calling tesseract.
|
||||
// Author: Ray Smith
|
||||
// Created: Fri Oct 06 15:35:01 PDT 2006
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_API_BASEAPI_H__
|
||||
#define TESSERACT_API_BASEAPI_H__
|
||||
|
||||
#include <stdio.h>
|
||||
// To avoid collision with other typenames include the ABSOLUTE MINIMUM
|
||||
// complexity of includes here. Use forward declarations wherever possible
|
||||
// and hide includes of complex types in baseapi.cpp.
|
||||
#include "platform.h"
|
||||
#include "apitypes.h"
|
||||
#include "thresholder.h"
|
||||
#include "unichar.h"
|
||||
#include "tesscallback.h"
|
||||
#include "publictypes.h"
|
||||
#include "pageiterator.h"
|
||||
#include "resultiterator.h"
|
||||
|
||||
template <typename T> class GenericVector;
|
||||
class PAGE_RES;
|
||||
class PAGE_RES_IT;
|
||||
class ParagraphModel;
|
||||
class BlamerBundle;
|
||||
class BLOCK_LIST;
|
||||
class DENORM;
|
||||
class IMAGE;
|
||||
class MATRIX;
|
||||
class PBLOB;
|
||||
class ROW;
|
||||
class STRING;
|
||||
class WERD;
|
||||
struct Pix;
|
||||
struct Box;
|
||||
struct Pixa;
|
||||
struct Boxa;
|
||||
class ETEXT_DESC;
|
||||
struct OSResults;
|
||||
class TBOX;
|
||||
class UNICHARSET;
|
||||
|
||||
// From oldlist.h
|
||||
// TODO(antonova): remove when oldlist is deprecated.
|
||||
struct list_rec;
|
||||
typedef list_rec *LIST;
|
||||
|
||||
#define MAX_NUM_INT_FEATURES 512
|
||||
struct INT_FEATURE_STRUCT;
|
||||
typedef INT_FEATURE_STRUCT *INT_FEATURE;
|
||||
typedef INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES];
|
||||
struct TBLOB;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class CubeRecoContext;
|
||||
class Dawg;
|
||||
class Dict;
|
||||
class EquationDetect;
|
||||
class LTRResultIterator;
|
||||
class MutableIterator;
|
||||
class Tesseract;
|
||||
class Trie;
|
||||
class Wordrec;
|
||||
|
||||
typedef int (Dict::*DictFunc)(void* void_dawg_args,
|
||||
UNICHAR_ID unichar_id, bool word_end) const;
|
||||
typedef double (Dict::*ProbabilityInContextFunc)(const char* lang,
|
||||
const char* context,
|
||||
int context_bytes,
|
||||
const char* character,
|
||||
int character_bytes);
|
||||
typedef void (Wordrec::*FillLatticeFunc)(const MATRIX &ratings,
|
||||
const LIST &best_choices,
|
||||
const UNICHARSET &unicharset,
|
||||
BlamerBundle *blamer_bundle);
|
||||
typedef TessCallback3<const UNICHARSET &, int, PAGE_RES *> TruthCallback;
|
||||
|
||||
/**
|
||||
* Base class for all tesseract APIs.
|
||||
* Specific classes can add ability to work on different inputs or produce
|
||||
* different outputs.
|
||||
* This class is mostly an interface layer on top of the Tesseract instance
|
||||
* class to hide the data types so that users of this class don't have to
|
||||
* include any other Tesseract headers.
|
||||
*/
|
||||
class TESS_API TessBaseAPI {
|
||||
public:
|
||||
TessBaseAPI();
|
||||
virtual ~TessBaseAPI();
|
||||
|
||||
/**
|
||||
* Returns the version identifier as a static string. Do not delete.
|
||||
*/
|
||||
static const char* Version();
|
||||
|
||||
/**
|
||||
* Set the name of the input file. Needed only for training and
|
||||
* reading a UNLV zone file.
|
||||
*/
|
||||
void SetInputName(const char* name);
|
||||
|
||||
/** Set the name of the bonus output files. Needed only for debugging. */
|
||||
void SetOutputName(const char* name);
|
||||
|
||||
/**
|
||||
* Set the value of an internal "parameter."
|
||||
* Supply the name of the parameter and the value as a string, just as
|
||||
* you would in a config file.
|
||||
* Returns false if the name lookup failed.
|
||||
* Eg SetVariable("tessedit_char_blacklist", "xyz"); to ignore x, y and z.
|
||||
* Or SetVariable("classify_bln_numeric_mode", "1"); to set numeric-only mode.
|
||||
* SetVariable may be used before Init, but settings will revert to
|
||||
* defaults on End().
|
||||
* TODO(rays) Add a command-line option to dump the parameters to stdout
|
||||
* and add a pointer to it in the FAQ
|
||||
*
|
||||
* Note: Must be called after Init(). Only works for non-init variables
|
||||
* (init variables should be passed to Init()).
|
||||
*/
|
||||
bool SetVariable(const char* name, const char* value);
|
||||
bool SetDebugVariable(const char* name, const char* value);
|
||||
|
||||
/**
|
||||
* Returns true if the parameter was found among Tesseract parameters.
|
||||
* Fills in value with the value of the parameter.
|
||||
*/
|
||||
bool GetIntVariable(const char *name, int *value) const;
|
||||
bool GetBoolVariable(const char *name, bool *value) const;
|
||||
bool GetDoubleVariable(const char *name, double *value) const;
|
||||
|
||||
/**
|
||||
* Returns the pointer to the string that represents the value of the
|
||||
* parameter if it was found among Tesseract parameters.
|
||||
*/
|
||||
const char *GetStringVariable(const char *name) const;
|
||||
|
||||
/**
|
||||
* Print Tesseract parameters to the given file.
|
||||
*/
|
||||
void PrintVariables(FILE *fp) const;
|
||||
|
||||
/**
|
||||
* Get value of named variable as a string, if it exists.
|
||||
*/
|
||||
bool GetVariableAsString(const char *name, STRING *val);
|
||||
|
||||
/**
|
||||
* Instances are now mostly thread-safe and totally independent,
|
||||
* but some global parameters remain. Basically it is safe to use multiple
|
||||
* TessBaseAPIs in different threads in parallel, UNLESS:
|
||||
* you use SetVariable on some of the Params in classify and textord.
|
||||
* If you do, then the effect will be to change it for all your instances.
|
||||
*
|
||||
* Start tesseract. Returns zero on success and -1 on failure.
|
||||
* NOTE that the only members that may be called before Init are those
|
||||
* listed above here in the class definition.
|
||||
*
|
||||
* The datapath must be the name of the parent directory of tessdata and
|
||||
* must end in / . Any name after the last / will be stripped.
|
||||
* The language is (usually) an ISO 639-3 string or NULL will default to eng.
|
||||
* It is entirely safe (and eventually will be efficient too) to call
|
||||
* Init multiple times on the same instance to change language, or just
|
||||
* to reset the classifier.
|
||||
* The language may be a string of the form [~]<lang>[+[~]<lang>]* indicating
|
||||
* that multiple languages are to be loaded. Eg hin+eng will load Hindi and
|
||||
* English. Languages may specify internally that they want to be loaded
|
||||
* with one or more other languages, so the ~ sign is available to override
|
||||
* that. Eg if hin were set to load eng by default, then hin+~eng would force
|
||||
* loading only hin. The number of loaded languages is limited only by
|
||||
* memory, with the caveat that loading additional languages will impact
|
||||
* both speed and accuracy, as there is more work to do to decide on the
|
||||
* applicable language, and there is more chance of hallucinating incorrect
|
||||
* words.
|
||||
* WARNING: On changing languages, all Tesseract parameters are reset
|
||||
* back to their default values. (Which may vary between languages.)
|
||||
* If you have a rare need to set a Variable that controls
|
||||
* initialization for a second call to Init you should explicitly
|
||||
* call End() and then use SetVariable before Init. This is only a very
|
||||
* rare use case, since there are very few uses that require any parameters
|
||||
* to be set before Init.
|
||||
*
|
||||
* If set_only_non_debug_params is true, only params that do not contain
|
||||
* "debug" in the name will be set.
|
||||
*/
|
||||
int Init(const char* datapath, const char* language, OcrEngineMode mode,
|
||||
char **configs, int configs_size,
|
||||
const GenericVector<STRING> *vars_vec,
|
||||
const GenericVector<STRING> *vars_values,
|
||||
bool set_only_non_debug_params);
|
||||
int Init(const char* datapath, const char* language, OcrEngineMode oem) {
|
||||
return Init(datapath, language, oem, NULL, 0, NULL, NULL, false);
|
||||
}
|
||||
int Init(const char* datapath, const char* language) {
|
||||
return Init(datapath, language, OEM_DEFAULT, NULL, 0, NULL, NULL, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the languages string used in the last valid initialization.
|
||||
* If the last initialization specified "deu+hin" then that will be
|
||||
* returned. If hin loaded eng automatically as well, then that will
|
||||
* not be included in this list. To find the languages actually
|
||||
* loaded use GetLoadedLanguagesAsVector.
|
||||
* The returned string should NOT be deleted.
|
||||
*/
|
||||
const char* GetInitLanguagesAsString() const;
|
||||
|
||||
/**
|
||||
* Returns the loaded languages in the vector of STRINGs.
|
||||
* Includes all languages loaded by the last Init, including those loaded
|
||||
* as dependencies of other loaded languages.
|
||||
*/
|
||||
void GetLoadedLanguagesAsVector(GenericVector<STRING>* langs) const;
|
||||
|
||||
/**
|
||||
* Returns the available languages in the vector of STRINGs.
|
||||
*/
|
||||
void GetAvailableLanguagesAsVector(GenericVector<STRING>* langs) const;
|
||||
|
||||
/**
|
||||
* Init only the lang model component of Tesseract. The only functions
|
||||
* that work after this init are SetVariable and IsValidWord.
|
||||
* WARNING: temporary! This function will be removed from here and placed
|
||||
* in a separate API at some future time.
|
||||
*/
|
||||
int InitLangMod(const char* datapath, const char* language);
|
||||
|
||||
/**
|
||||
* Init only for page layout analysis. Use only for calls to SetImage and
|
||||
* AnalysePage. Calls that attempt recognition will generate an error.
|
||||
*/
|
||||
void InitForAnalysePage();
|
||||
|
||||
/**
|
||||
* Read a "config" file containing a set of param, value pairs.
|
||||
* Searches the standard places: tessdata/configs, tessdata/tessconfigs
|
||||
* and also accepts a relative or absolute path name.
|
||||
* Note: only non-init params will be set (init params are set by Init()).
|
||||
*/
|
||||
void ReadConfigFile(const char* filename);
|
||||
/** Same as above, but only set debug params from the given config file. */
|
||||
void ReadDebugConfigFile(const char* filename);
|
||||
|
||||
/**
|
||||
* Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK.
|
||||
* The mode is stored as an IntParam so it can also be modified by
|
||||
* ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string).
|
||||
*/
|
||||
void SetPageSegMode(PageSegMode mode);
|
||||
|
||||
/** Return the current page segmentation mode. */
|
||||
PageSegMode GetPageSegMode() const;
|
||||
|
||||
/**
|
||||
* Recognize a rectangle from an image and return the result as a string.
|
||||
* May be called many times for a single Init.
|
||||
* Currently has no error checking.
|
||||
* Greyscale of 8 and color of 24 or 32 bits per pixel may be given.
|
||||
* Palette color images will not work properly and must be converted to
|
||||
* 24 bit.
|
||||
* Binary images of 1 bit per pixel may also be given but they must be
|
||||
* byte packed with the MSB of the first byte being the first pixel, and a
|
||||
* 1 represents WHITE. For binary images set bytes_per_pixel=0.
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UTF8 and must be freed with the delete [] operator.
|
||||
*
|
||||
* Note that TesseractRect is the simplified convenience interface.
|
||||
* For advanced uses, use SetImage, (optionally) SetRectangle, Recognize,
|
||||
* and one or more of the Get*Text functions below.
|
||||
*/
|
||||
char* TesseractRect(const unsigned char* imagedata,
|
||||
int bytes_per_pixel, int bytes_per_line,
|
||||
int left, int top, int width, int height);
|
||||
|
||||
/**
|
||||
* Call between pages or documents etc to free up memory and forget
|
||||
* adaptive data.
|
||||
*/
|
||||
void ClearAdaptiveClassifier();
|
||||
|
||||
/**
|
||||
* @defgroup AdvancedAPI Advanced API
|
||||
* The following methods break TesseractRect into pieces, so you can
|
||||
* get hold of the thresholded image, get the text in different formats,
|
||||
* get bounding boxes, confidences etc.
|
||||
*/
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
* Provide an image for Tesseract to recognize. Format is as
|
||||
* TesseractRect above. Does not copy the image buffer, or take
|
||||
* ownership. The source image may be destroyed after Recognize is called,
|
||||
* either explicitly or implicitly via one of the Get*Text functions.
|
||||
* SetImage clears all recognition results, and sets the rectangle to the
|
||||
* full image, so it may be followed immediately by a GetUTF8Text, and it
|
||||
* will automatically perform recognition.
|
||||
*/
|
||||
void SetImage(const unsigned char* imagedata, int width, int height,
|
||||
int bytes_per_pixel, int bytes_per_line);
|
||||
|
||||
/**
|
||||
* Provide an image for Tesseract to recognize. As with SetImage above,
|
||||
* Tesseract doesn't take a copy or ownership or pixDestroy the image, so
|
||||
* it must persist until after Recognize.
|
||||
* Pix vs raw, which to use?
|
||||
* Use Pix where possible. A future version of Tesseract may choose to use Pix
|
||||
* as its internal representation and discard IMAGE altogether.
|
||||
* Because of that, an implementation that sources and targets Pix may end up
|
||||
* with less copies than an implementation that does not.
|
||||
*/
|
||||
void SetImage(const Pix* pix);
|
||||
|
||||
/**
|
||||
* Set the resolution of the source image in pixels per inch so font size
|
||||
* information can be calculated in results. Call this after SetImage().
|
||||
*/
|
||||
void SetSourceResolution(int ppi);
|
||||
|
||||
/**
|
||||
* Restrict recognition to a sub-rectangle of the image. Call after SetImage.
|
||||
* Each SetRectangle clears the recogntion results so multiple rectangles
|
||||
* can be recognized with the same image.
|
||||
*/
|
||||
void SetRectangle(int left, int top, int width, int height);
|
||||
|
||||
/**
|
||||
* In extreme cases only, usually with a subclass of Thresholder, it
|
||||
* is possible to provide a different Thresholder. The Thresholder may
|
||||
* be preloaded with an image, settings etc, or they may be set after.
|
||||
* Note that Tesseract takes ownership of the Thresholder and will
|
||||
* delete it when it it is replaced or the API is destructed.
|
||||
*/
|
||||
void SetThresholder(ImageThresholder* thresholder) {
|
||||
if (thresholder_ != NULL)
|
||||
delete thresholder_;
|
||||
thresholder_ = thresholder;
|
||||
ClearResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the internal thresholded image from Tesseract.
|
||||
* Caller takes ownership of the Pix and must pixDestroy it.
|
||||
* May be called any time after SetImage, or after TesseractRect.
|
||||
*/
|
||||
Pix* GetThresholdedImage();
|
||||
|
||||
/**
|
||||
* Get the result of page layout analysis as a leptonica-style
|
||||
* Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
*/
|
||||
Boxa* GetRegions(Pixa** pixa);
|
||||
|
||||
/**
|
||||
* Get the textlines as a leptonica-style
|
||||
* Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
* If blockids is not NULL, the block-id of each line is also returned
|
||||
* as an array of one element per line. delete [] after use.
|
||||
*/
|
||||
Boxa* GetTextlines(Pixa** pixa, int** blockids);
|
||||
|
||||
/**
|
||||
* Get textlines and strips of image regions as a leptonica-style Boxa, Pixa
|
||||
* pair, in reading order. Enables downstream handling of non-rectangular
|
||||
* regions.
|
||||
* Can be called before or after Recognize.
|
||||
* If blockids is not NULL, the block-id of each line is also returned as an
|
||||
* array of one element per line. delete [] after use.
|
||||
*/
|
||||
Boxa* GetStrips(Pixa** pixa, int** blockids);
|
||||
|
||||
/**
|
||||
* Get the words as a leptonica-style
|
||||
* Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
*/
|
||||
Boxa* GetWords(Pixa** pixa);
|
||||
|
||||
/**
|
||||
* Gets the individual connected (text) components (created
|
||||
* after pages segmentation step, but before recognition)
|
||||
* as a leptonica-style Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
* Note: the caller is responsible for calling boxaDestroy()
|
||||
* on the returned Boxa array and pixaDestroy() on cc array.
|
||||
*/
|
||||
Boxa* GetConnectedComponents(Pixa** cc);
|
||||
|
||||
/**
|
||||
* Get the given level kind of components (block, textline, word etc.) as a
|
||||
* leptonica-style Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
* If blockids is not NULL, the block-id of each component is also returned
|
||||
* as an array of one element per component. delete [] after use.
|
||||
* If text_only is true, then only text components are returned.
|
||||
*/
|
||||
Boxa* GetComponentImages(PageIteratorLevel level,
|
||||
bool text_only,
|
||||
Pixa** pixa, int** blockids);
|
||||
|
||||
/**
|
||||
* Returns the scale factor of the thresholded image that would be returned by
|
||||
* GetThresholdedImage() and the various GetX() methods that call
|
||||
* GetComponentImages().
|
||||
* Returns 0 if no thresholder has been set.
|
||||
*/
|
||||
int GetThresholdedImageScaleFactor() const;
|
||||
|
||||
/**
|
||||
* Dump the internal binary image to a PGM file.
|
||||
* @deprecated Use GetThresholdedImage and write the image using pixWrite
|
||||
* instead if possible.
|
||||
*/
|
||||
void DumpPGM(const char* filename);
|
||||
|
||||
/**
|
||||
* Runs page layout analysis in the mode set by SetPageSegMode.
|
||||
* May optionally be called prior to Recognize to get access to just
|
||||
* the page layout results. Returns an iterator to the results.
|
||||
* Returns NULL on error.
|
||||
* The returned iterator must be deleted after use.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
*/
|
||||
PageIterator* AnalyseLayout();
|
||||
|
||||
/**
|
||||
* Recognize the image from SetAndThresholdImage, generating Tesseract
|
||||
* internal structures. Returns 0 on success.
|
||||
* Optional. The Get*Text functions below will call Recognize if needed.
|
||||
* After Recognize, the output is kept internally until the next SetImage.
|
||||
*/
|
||||
int Recognize(ETEXT_DESC* monitor);
|
||||
|
||||
/**
|
||||
* Methods to retrieve information after SetAndThresholdImage(),
|
||||
* Recognize() or TesseractRect(). (Recognize is called implicitly if needed.)
|
||||
*/
|
||||
|
||||
/** Variant on Recognize used for testing chopper. */
|
||||
int RecognizeForChopTest(ETEXT_DESC* monitor);
|
||||
|
||||
/**
|
||||
* Recognizes all the pages in the named file, as a multi-page tiff or
|
||||
* list of filenames, or single image, and gets the appropriate kind of text
|
||||
* according to parameters: tessedit_create_boxfile,
|
||||
* tessedit_make_boxes_from_boxes, tessedit_write_unlv, tessedit_create_hocr.
|
||||
* Calls ProcessPage on each page in the input file, which may be a
|
||||
* multi-page tiff, single-page other file format, or a plain text list of
|
||||
* images to read. If tessedit_page_number is non-negative, processing begins
|
||||
* at that page of a multi-page tiff file, or filelist.
|
||||
* The text is returned in text_out. Returns false on error.
|
||||
* If non-zero timeout_millisec terminates processing after the timeout on
|
||||
* a single page.
|
||||
* If non-NULL and non-empty, and some page fails for some reason,
|
||||
* the page is reprocessed with the retry_config config file. Useful
|
||||
* for interactively debugging a bad page.
|
||||
*/
|
||||
bool ProcessPages(const char* filename,
|
||||
const char* retry_config, int timeout_millisec,
|
||||
STRING* text_out);
|
||||
|
||||
/**
|
||||
* Recognizes a single page for ProcessPages, appending the text to text_out.
|
||||
* The pix is the image processed - filename and page_index are metadata
|
||||
* used by side-effect processes, such as reading a box file or formatting
|
||||
* as hOCR.
|
||||
* If non-zero timeout_millisec terminates processing after the timeout.
|
||||
* If non-NULL and non-empty, and some page fails for some reason,
|
||||
* the page is reprocessed with the retry_config config file. Useful
|
||||
* for interactively debugging a bad page.
|
||||
* The text is returned in text_out. Returns false on error.
|
||||
*/
|
||||
bool ProcessPage(Pix* pix, int page_index, const char* filename,
|
||||
const char* retry_config, int timeout_millisec,
|
||||
STRING* text_out);
|
||||
|
||||
/**
|
||||
* Get a reading-order iterator to the results of LayoutAnalysis and/or
|
||||
* Recognize. The returned iterator must be deleted after use.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
*/
|
||||
ResultIterator* GetIterator();
|
||||
|
||||
/**
|
||||
* Get a mutable iterator to the results of LayoutAnalysis and/or Recognize.
|
||||
* The returned iterator must be deleted after use.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
*/
|
||||
MutableIterator* GetMutableIterator();
|
||||
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UTF8 and must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetUTF8Text();
|
||||
|
||||
/**
|
||||
* Make a HTML-formatted string with hOCR markup from the internal
|
||||
* data structures.
|
||||
* page_number is 0-based but will appear in the output as 1-based.
|
||||
*/
|
||||
char* GetHOCRText(int page_number);
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded in the same
|
||||
* format as a box file used in training. Returned string must be freed with
|
||||
* the delete [] operator.
|
||||
* Constructs coordinates in the original image - not just the rectangle.
|
||||
* page_number is a 0-based page index that will appear in the box file.
|
||||
*/
|
||||
char* GetBoxText(int page_number);
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UNLV format Latin-1 with specific reject and suspect codes
|
||||
* and must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetUNLVText();
|
||||
/** Returns the (average) confidence value between 0 and 100. */
|
||||
int MeanTextConf();
|
||||
/**
|
||||
* Returns all word confidences (between 0 and 100) in an array, terminated
|
||||
* by -1. The calling function must delete [] after use.
|
||||
* The number of confidences should correspond to the number of space-
|
||||
* delimited words in GetUTF8Text.
|
||||
*/
|
||||
int* AllWordConfidences();
|
||||
|
||||
/**
|
||||
* Applies the given word to the adaptive classifier if possible.
|
||||
* The word must be SPACE-DELIMITED UTF-8 - l i k e t h i s , so it can
|
||||
* tell the boundaries of the graphemes.
|
||||
* Assumes that SetImage/SetRectangle have been used to set the image
|
||||
* to the given word. The mode arg should be PSM_SINGLE_WORD or
|
||||
* PSM_CIRCLE_WORD, as that will be used to control layout analysis.
|
||||
* The currently set PageSegMode is preserved.
|
||||
* Returns false if adaption was not possible for some reason.
|
||||
*/
|
||||
bool AdaptToWordStr(PageSegMode mode, const char* wordstr);
|
||||
|
||||
/**
|
||||
* Free up recognition results and any stored image data, without actually
|
||||
* freeing any recognition data that would be time-consuming to reload.
|
||||
* Afterwards, you must call SetImage or TesseractRect before doing
|
||||
* any Recognize or Get* operation.
|
||||
*/
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
* Close down tesseract and free up all memory. End() is equivalent to
|
||||
* destructing and reconstructing your TessBaseAPI.
|
||||
* Once End() has been used, none of the other API functions may be used
|
||||
* other than Init and anything declared above it in the class definition.
|
||||
*/
|
||||
void End();
|
||||
|
||||
/**
|
||||
* Check whether a word is valid according to Tesseract's language model
|
||||
* @return 0 if the word is invalid, non-zero if valid.
|
||||
* @warning temporary! This function will be removed from here and placed
|
||||
* in a separate API at some future time.
|
||||
*/
|
||||
int IsValidWord(const char *word);
|
||||
|
||||
bool GetTextDirection(int* out_offset, float* out_slope);
|
||||
|
||||
/** Sets Dict::letter_is_okay_ function to point to the given function. */
|
||||
void SetDictFunc(DictFunc f);
|
||||
|
||||
/** Sets Dict::probability_in_context_ function to point to the given
|
||||
* function.
|
||||
*/
|
||||
void SetProbabilityInContextFunc(ProbabilityInContextFunc f);
|
||||
|
||||
/** Sets Wordrec::fill_lattice_ function to point to the given function. */
|
||||
void SetFillLatticeFunc(FillLatticeFunc f);
|
||||
|
||||
/**
|
||||
* Estimates the Orientation And Script of the image.
|
||||
* @return true if the image was processed successfully.
|
||||
*/
|
||||
bool DetectOS(OSResults*);
|
||||
|
||||
/** This method returns the features associated with the input image. */
|
||||
void GetFeaturesForBlob(TBLOB* blob, const DENORM& denorm,
|
||||
INT_FEATURE_ARRAY int_features,
|
||||
int* num_features, int* FeatureOutlineIndex);
|
||||
|
||||
/**
|
||||
* This method returns the row to which a box of specified dimensions would
|
||||
* belong. If no good match is found, it returns NULL.
|
||||
*/
|
||||
static ROW* FindRowForBox(BLOCK_LIST* blocks, int left, int top,
|
||||
int right, int bottom);
|
||||
|
||||
/**
|
||||
* Method to run adaptive classifier on a blob.
|
||||
* It returns at max num_max_matches results.
|
||||
*/
|
||||
void RunAdaptiveClassifier(TBLOB* blob, const DENORM& denorm,
|
||||
int num_max_matches,
|
||||
int* unichar_ids,
|
||||
float* ratings,
|
||||
int* num_matches_returned);
|
||||
|
||||
/** This method returns the string form of the specified unichar. */
|
||||
const char* GetUnichar(int unichar_id);
|
||||
|
||||
/** Return the pointer to the i-th dawg loaded into tesseract_ object. */
|
||||
const Dawg *GetDawg(int i) const;
|
||||
|
||||
/** Return the number of dawgs loaded into tesseract_ object. */
|
||||
int NumDawgs() const;
|
||||
|
||||
/** Returns a ROW object created from the input row specification. */
|
||||
static ROW *MakeTessOCRRow(float baseline, float xheight,
|
||||
float descender, float ascender);
|
||||
|
||||
/** Returns a TBLOB corresponding to the entire input image. */
|
||||
static TBLOB *MakeTBLOB(Pix *pix);
|
||||
|
||||
/**
|
||||
* This method baseline normalizes a TBLOB in-place. The input row is used
|
||||
* for normalization. The denorm is an optional parameter in which the
|
||||
* normalization-antidote is returned.
|
||||
*/
|
||||
static void NormalizeTBLOB(TBLOB *tblob, ROW *row,
|
||||
bool numeric_mode, DENORM *denorm);
|
||||
|
||||
Tesseract* const tesseract() const {
|
||||
return tesseract_;
|
||||
}
|
||||
|
||||
OcrEngineMode const oem() const {
|
||||
return last_oem_requested_;
|
||||
}
|
||||
|
||||
void InitTruthCallback(TruthCallback *cb) { truth_cb_ = cb; }
|
||||
|
||||
/** Return a pointer to underlying CubeRecoContext object if present. */
|
||||
CubeRecoContext *GetCubeRecoContext() const;
|
||||
|
||||
void set_min_orientation_margin(double margin);
|
||||
|
||||
/**
|
||||
* Return text orientation of each block as determined by an earlier run
|
||||
* of layout analysis.
|
||||
*/
|
||||
void GetBlockTextOrientations(int** block_orientation,
|
||||
bool** vertical_writing);
|
||||
|
||||
/** Find lines from the image making the BLOCK_LIST. */
|
||||
BLOCK_LIST* FindLinesCreateBlockList();
|
||||
|
||||
/**
|
||||
* Delete a block list.
|
||||
* This is to keep BLOCK_LIST pointer opaque
|
||||
* and let go of including the other headers.
|
||||
*/
|
||||
static void DeleteBlockList(BLOCK_LIST* block_list);
|
||||
/* @} */
|
||||
|
||||
protected:
|
||||
|
||||
/** Common code for setting the image. Returns true if Init has been called. */
|
||||
TESS_LOCAL bool InternalSetImage();
|
||||
|
||||
/**
|
||||
* Run the thresholder to make the thresholded image. If pix is not NULL,
|
||||
* the source is thresholded to pix instead of the internal IMAGE.
|
||||
*/
|
||||
TESS_LOCAL virtual void Threshold(Pix** pix);
|
||||
|
||||
/**
|
||||
* Find lines from the image making the BLOCK_LIST.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
TESS_LOCAL int FindLines();
|
||||
|
||||
/** Delete the pageres and block list ready for a new page. */
|
||||
TESS_LOCAL void ClearResults();
|
||||
|
||||
/**
|
||||
* Return an LTR Result Iterator -- used only for training, as we really want
|
||||
* to ignore all BiDi smarts at that point.
|
||||
* delete once you're done with it.
|
||||
*/
|
||||
TESS_LOCAL LTRResultIterator* GetLTRIterator();
|
||||
|
||||
/**
|
||||
* Return the length of the output text string, as UTF8, assuming
|
||||
* one newline per line and one per block, with a terminator,
|
||||
* and assuming a single character reject marker for each rejected character.
|
||||
* Also return the number of recognized blobs in blob_count.
|
||||
*/
|
||||
TESS_LOCAL int TextLength(int* blob_count);
|
||||
|
||||
/** @defgroup ocropusAddOns ocropus add-ons */
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
* Adapt to recognize the current image as the given character.
|
||||
* The image must be preloaded and be just an image of a single character.
|
||||
*/
|
||||
TESS_LOCAL void AdaptToCharacter(const char *unichar_repr,
|
||||
int length,
|
||||
float baseline,
|
||||
float xheight,
|
||||
float descender,
|
||||
float ascender);
|
||||
|
||||
/** Recognize text doing one pass only, using settings for a given pass. */
|
||||
TESS_LOCAL PAGE_RES* RecognitionPass1(BLOCK_LIST* block_list);
|
||||
TESS_LOCAL PAGE_RES* RecognitionPass2(BLOCK_LIST* block_list, PAGE_RES* pass1_result);
|
||||
|
||||
//// paragraphs.cpp ////////////////////////////////////////////////////
|
||||
TESS_LOCAL void DetectParagraphs(bool after_text_recognition);
|
||||
|
||||
/**
|
||||
* Extract the OCR results, costs (penalty points for uncertainty),
|
||||
* and the bounding boxes of the characters.
|
||||
*/
|
||||
TESS_LOCAL static int TesseractExtractResult(char** text,
|
||||
int** lengths,
|
||||
float** costs,
|
||||
int** x0,
|
||||
int** y0,
|
||||
int** x1,
|
||||
int** y1,
|
||||
PAGE_RES* page_res);
|
||||
|
||||
TESS_LOCAL const PAGE_RES* GetPageRes() const {
|
||||
return page_res_;
|
||||
};
|
||||
/* @} */
|
||||
|
||||
protected:
|
||||
Tesseract* tesseract_; ///< The underlying data object.
|
||||
Tesseract* osd_tesseract_; ///< For orientation & script detection.
|
||||
EquationDetect* equ_detect_; ///<The equation detector.
|
||||
ImageThresholder* thresholder_; ///< Image thresholding module.
|
||||
GenericVector<ParagraphModel *>* paragraph_models_;
|
||||
BLOCK_LIST* block_list_; ///< The page layout.
|
||||
PAGE_RES* page_res_; ///< The page-level data.
|
||||
STRING* input_file_; ///< Name used by training code.
|
||||
STRING* output_file_; ///< Name used by debug code.
|
||||
STRING* datapath_; ///< Current location of tessdata.
|
||||
STRING* language_; ///< Last initialized language.
|
||||
OcrEngineMode last_oem_requested_; ///< Last ocr language mode requested.
|
||||
bool recognition_done_; ///< page_res_ contains recognition data.
|
||||
TruthCallback *truth_cb_; /// fxn for setting truth_* in WERD_RES
|
||||
|
||||
/**
|
||||
* @defgroup ThresholderParams Thresholder Parameters
|
||||
* Parameters saved from the Thresholder. Needed to rebuild coordinates.
|
||||
*/
|
||||
/* @{ */
|
||||
int rect_left_;
|
||||
int rect_top_;
|
||||
int rect_width_;
|
||||
int rect_height_;
|
||||
int image_width_;
|
||||
int image_height_;
|
||||
/* @} */
|
||||
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_API_BASEAPI_H__
|
||||
@@ -1,31 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: basedir.h (Formerly getpath.h)
|
||||
* Description: Header file for getpath.c. Provides relocatability of data.
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Jul 09 09:13:03 BST 1990
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef BASEDIR_H
|
||||
#define BASEDIR_H
|
||||
|
||||
#include "platform.h"
|
||||
#include "strngs.h"
|
||||
|
||||
// Returns the given code_path truncated to the last slash.
|
||||
// Useful for getting to the directory of argv[0], but does not search
|
||||
// any paths.
|
||||
TESS_API void truncate_path(const char *code_path, STRING* trunc_path);
|
||||
|
||||
#endif
|
||||
@@ -1,297 +0,0 @@
|
||||
#ifndef TESSERACT_API_CAPI_H__
|
||||
#define TESSERACT_API_CAPI_H__
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
# include "baseapi.h"
|
||||
# include "pageiterator.h"
|
||||
# include "resultiterator.h"
|
||||
#else
|
||||
# include "platform.h"
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef TESS_CALL
|
||||
# if defined(WIN32)
|
||||
# define TESS_CALL __cdecl
|
||||
# else
|
||||
# define TESS_CALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOL
|
||||
# define BOOL int
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
typedef tesseract::TessBaseAPI TessBaseAPI;
|
||||
typedef tesseract::PageIterator TessPageIterator;
|
||||
typedef tesseract::ResultIterator TessResultIterator;
|
||||
typedef tesseract::MutableIterator TessMutableIterator;
|
||||
typedef tesseract::OcrEngineMode TessOcrEngineMode;
|
||||
typedef tesseract::PageSegMode TessPageSegMode;
|
||||
typedef tesseract::ImageThresholder TessImageThresholder;
|
||||
typedef tesseract::PageIteratorLevel TessPageIteratorLevel;
|
||||
typedef tesseract::DictFunc TessDictFunc;
|
||||
typedef tesseract::ProbabilityInContextFunc TessProbabilityInContextFunc;
|
||||
typedef tesseract::FillLatticeFunc TessFillLatticeFunc;
|
||||
typedef tesseract::Dawg TessDawg;
|
||||
typedef tesseract::TruthCallback TessTruthCallback;
|
||||
typedef tesseract::CubeRecoContext TessCubeRecoContext;
|
||||
typedef tesseract::Orientation TessOrientation;
|
||||
typedef tesseract::WritingDirection TessWritingDirection;
|
||||
typedef tesseract::TextlineOrder TessTextlineOrder;
|
||||
typedef PolyBlockType TessPolyBlockType;
|
||||
typedef Pix PIX;
|
||||
typedef Boxa BOXA;
|
||||
typedef Pixa PIXA;
|
||||
#else
|
||||
typedef struct TessBaseAPI TessBaseAPI;
|
||||
typedef struct TessPageIterator TessPageIterator;
|
||||
typedef struct TessResultIterator TessResultIterator;
|
||||
typedef struct TessMutableIterator TessMutableIterator;
|
||||
typedef enum TessOcrEngineMode { OEM_TESSERACT_ONLY, OEM_CUBE_ONLY, OEM_TESSERACT_CUBE_COMBINED, OEM_DEFAULT } TessOcrEngineMode;
|
||||
typedef enum TessPageSegMode { PSM_OSD_ONLY, PSM_AUTO_OSD, PSM_AUTO_ONLY, PSM_AUTO, PSM_SINGLE_COLUMN, PSM_SINGLE_BLOCK_VERT_TEXT,
|
||||
PSM_SINGLE_BLOCK, PSM_SINGLE_LINE, PSM_SINGLE_WORD, PSM_CIRCLE_WORD, PSM_SINGLE_CHAR, PSM_COUNT } TessPageSegMode;
|
||||
typedef enum TessPageIteratorLevel { RIL_BLOCK, RIL_PARA, RIL_TEXTLINE, RIL_WORD, RIL_SYMBOL} TessPageIteratorLevel;
|
||||
typedef enum TessPolyBlockType { PT_UNKNOWN, PT_FLOWING_TEXT, PT_HEADING_TEXT, PT_PULLOUT_TEXT, PT_TABLE, PT_VERTICAL_TEXT,
|
||||
PT_CAPTION_TEXT, PT_FLOWING_IMAGE, PT_HEADING_IMAGE, PT_PULLOUT_IMAGE, PT_HORZ_LINE, PT_VERT_LINE,
|
||||
PT_NOISE, PT_COUNT } TessPolyBlockType;
|
||||
typedef enum TessOrientation { ORIENTATION_PAGE_UP, ORIENTATION_PAGE_RIGHT, ORIENTATION_PAGE_DOWN, ORIENTATION_PAGE_LEFT } TessOrientation;
|
||||
typedef enum TessWritingDirection { WRITING_DIRECTION_LEFT_TO_RIGHT, WRITING_DIRECTION_RIGHT_TO_LEFT, WRITING_DIRECTION_TOP_TO_BOTTOM } TessWritingDirection;
|
||||
typedef enum TessTextlineOrder { TEXTLINE_ORDER_LEFT_TO_RIGHT, TEXTLINE_ORDER_RIGHT_TO_LEFT, TEXTLINE_ORDER_TOP_TO_BOTTOM } TessTextlineOrder;
|
||||
typedef struct ETEXT_DESC ETEXT_DESC;
|
||||
typedef struct Pix PIX;
|
||||
typedef struct Boxa BOXA;
|
||||
typedef struct Pixa PIXA;
|
||||
#endif
|
||||
|
||||
/* General free functions */
|
||||
|
||||
TESS_API const char*
|
||||
TESS_CALL TessVersion();
|
||||
TESS_API void TESS_CALL TessDeleteText(char* text);
|
||||
TESS_API void TESS_CALL TessDeleteTextArray(char** arr);
|
||||
TESS_API void TESS_CALL TessDeleteIntArray(int* arr);
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API void TESS_CALL TessDeleteBlockList(BLOCK_LIST* block_list);
|
||||
#endif
|
||||
|
||||
/* Base API */
|
||||
|
||||
TESS_API TessBaseAPI*
|
||||
TESS_CALL TessBaseAPICreate();
|
||||
TESS_API void TESS_CALL TessBaseAPIDelete(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetInputName( TessBaseAPI* handle, const char* name);
|
||||
TESS_API void TESS_CALL TessBaseAPISetOutputName(TessBaseAPI* handle, const char* name);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessBaseAPISetVariable(TessBaseAPI* handle, const char* name, const char* value);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPISetDebugVariable(TessBaseAPI* handle, const char* name, const char* value);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable( const TessBaseAPI* handle, const char* name, int* value);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable( const TessBaseAPI* handle, const char* name, BOOL* value);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetDoubleVariable(const TessBaseAPI* handle, const char* name, double* value);
|
||||
TESS_API const char*
|
||||
TESS_CALL TessBaseAPIGetStringVariable(const TessBaseAPI* handle, const char* name);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIPrintVariables( const TessBaseAPI* handle, FILE* fp);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIPrintVariablesToFile(const TessBaseAPI* handle, const char* filename);
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetVariableAsString(TessBaseAPI* handle, const char* name, STRING* val);
|
||||
#endif
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API int TESS_CALL TessBaseAPIInit(TessBaseAPI* handle, const char* datapath, const char* language,
|
||||
TessOcrEngineMode mode, char** configs, int configs_size,
|
||||
const STRING* vars_vec, size_t vars_vec_size,
|
||||
const STRING* vars_values, size_t vars_values_size, BOOL set_only_init_params);
|
||||
#endif
|
||||
TESS_API int TESS_CALL TessBaseAPIInit1(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode oem,
|
||||
char** configs, int configs_size);
|
||||
TESS_API int TESS_CALL TessBaseAPIInit2(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode oem);
|
||||
TESS_API int TESS_CALL TessBaseAPIInit3(TessBaseAPI* handle, const char* datapath, const char* language);
|
||||
|
||||
TESS_API const char*
|
||||
TESS_CALL TessBaseAPIGetInitLanguagesAsString(const TessBaseAPI* handle);
|
||||
TESS_API char**
|
||||
TESS_CALL TessBaseAPIGetLoadedLanguagesAsVector(const TessBaseAPI* handle);
|
||||
TESS_API char**
|
||||
TESS_CALL TessBaseAPIGetAvailableLanguagesAsVector(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIInitLangMod(TessBaseAPI* handle, const char* datapath, const char* language);
|
||||
TESS_API void TESS_CALL TessBaseAPIInitForAnalysePage(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIReadConfigFile(TessBaseAPI* handle, const char* filename);
|
||||
TESS_API void TESS_CALL TessBaseAPIReadDebugConfigFile(TessBaseAPI* handle, const char* filename);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetPageSegMode(TessBaseAPI* handle, TessPageSegMode mode);
|
||||
TESS_API TessPageSegMode
|
||||
TESS_CALL TessBaseAPIGetPageSegMode(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIRect(TessBaseAPI* handle, const unsigned char* imagedata,
|
||||
int bytes_per_pixel, int bytes_per_line,
|
||||
int left, int top, int width, int height);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIClearAdaptiveClassifier(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetImage(TessBaseAPI* handle, const unsigned char* imagedata, int width, int height,
|
||||
int bytes_per_pixel, int bytes_per_line);
|
||||
TESS_API void TESS_CALL TessBaseAPISetImage2(TessBaseAPI* handle, const PIX* pix);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetSourceResolution(TessBaseAPI* handle, int ppi);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetRectangle(TessBaseAPI* handle, int left, int top, int width, int height);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API void TESS_CALL TessBaseAPISetThresholder(TessBaseAPI* handle, TessImageThresholder* thresholder);
|
||||
#endif
|
||||
|
||||
TESS_API PIX* TESS_CALL TessBaseAPIGetThresholdedImage( TessBaseAPI* handle);
|
||||
TESS_API BOXA* TESS_CALL TessBaseAPIGetRegions( TessBaseAPI* handle, PIXA** pixa);
|
||||
TESS_API BOXA* TESS_CALL TessBaseAPIGetTextlines( TessBaseAPI* handle, PIXA** pixa, int** blockids);
|
||||
TESS_API BOXA* TESS_CALL TessBaseAPIGetStrips( TessBaseAPI* handle, PIXA** pixa, int** blockids);
|
||||
TESS_API BOXA* TESS_CALL TessBaseAPIGetWords( TessBaseAPI* handle, PIXA** pixa);
|
||||
TESS_API BOXA* TESS_CALL TessBaseAPIGetConnectedComponents(TessBaseAPI* handle, PIXA** cc);
|
||||
TESS_API BOXA* TESS_CALL TessBaseAPIGetComponentImages( TessBaseAPI* handle, TessPageIteratorLevel level, BOOL text_only, PIXA** pixa, int** blockids);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIGetThresholdedImageScaleFactor(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIDumpPGM(TessBaseAPI* handle, const char* filename);
|
||||
|
||||
TESS_API TessPageIterator*
|
||||
TESS_CALL TessBaseAPIAnalyseLayout(TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIRecognize(TessBaseAPI* handle, ETEXT_DESC* monitor);
|
||||
TESS_API int TESS_CALL TessBaseAPIRecognizeForChopTest(TessBaseAPI* handle, ETEXT_DESC* monitor);
|
||||
TESS_API char* TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle, const char* filename, const char* retry_config,
|
||||
int timeout_millisec);
|
||||
TESS_API char* TESS_CALL TessBaseAPIProcessPage(TessBaseAPI* handle, PIX* pix, int page_index, const char* filename,
|
||||
const char* retry_config, int timeout_millisec);
|
||||
|
||||
TESS_API TessResultIterator*
|
||||
TESS_CALL TessBaseAPIGetIterator(TessBaseAPI* handle);
|
||||
TESS_API TessMutableIterator*
|
||||
TESS_CALL TessBaseAPIGetMutableIterator(TessBaseAPI* handle);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI* handle);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI* handle, int page_number);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI* handle, int page_number);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetUNLVText(TessBaseAPI* handle);
|
||||
TESS_API int TESS_CALL TessBaseAPIMeanTextConf(TessBaseAPI* handle);
|
||||
TESS_API int* TESS_CALL TessBaseAPIAllWordConfidences(TessBaseAPI* handle);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIAdaptToWordStr(TessBaseAPI* handle, TessPageSegMode mode, const char* wordstr);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIClear(TessBaseAPI* handle);
|
||||
TESS_API void TESS_CALL TessBaseAPIEnd(TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIIsValidWord(TessBaseAPI* handle, const char *word);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetTextDirection(TessBaseAPI* handle, int* out_offset, float* out_slope);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API void TESS_CALL TessBaseAPISetDictFunc(TessBaseAPI* handle, TessDictFunc f);
|
||||
TESS_API void TESS_CALL TessBaseAPISetProbabilityInContextFunc(TessBaseAPI* handle, TessProbabilityInContextFunc f);
|
||||
TESS_API void TESS_CALL TessBaseAPISetFillLatticeFunc(TessBaseAPI* handle, TessFillLatticeFunc f);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIDetectOS(TessBaseAPI* handle, OSResults* results);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIGetFeaturesForBlob(TessBaseAPI* handle, TBLOB* blob, const DENORM* denorm, INT_FEATURE_ARRAY int_features,
|
||||
int* num_features, int* FeatureOutlineIndex);
|
||||
|
||||
TESS_API ROW* TESS_CALL TessFindRowForBox(BLOCK_LIST* blocks, int left, int top, int right, int bottom);
|
||||
TESS_API void TESS_CALL TessBaseAPIRunAdaptiveClassifier(TessBaseAPI* handle, TBLOB* blob, const DENORM* denorm, int num_max_matches,
|
||||
int* unichar_ids, float* ratings, int* num_matches_returned);
|
||||
#endif
|
||||
|
||||
TESS_API const char*
|
||||
TESS_CALL TessBaseAPIGetUnichar(TessBaseAPI* handle, int unichar_id);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API const TessDawg*
|
||||
TESS_CALL TessBaseAPIGetDawg(const TessBaseAPI* handle, int i);
|
||||
TESS_API int TESS_CALL TessBaseAPINumDawgs(const TessBaseAPI* handle);
|
||||
#endif
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API ROW* TESS_CALL TessMakeTessOCRRow(float baseline, float xheight, float descender, float ascender);
|
||||
TESS_API TBLOB*
|
||||
TESS_CALL TessMakeTBLOB(Pix *pix);
|
||||
TESS_API void TESS_CALL TessNormalizeTBLOB(TBLOB *tblob, ROW *row, BOOL numeric_mode, DENORM *denorm);
|
||||
|
||||
TESS_API TessOcrEngineMode
|
||||
TESS_CALL TessBaseAPIOem(const TessBaseAPI* handle);
|
||||
TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI* handle, TessTruthCallback *cb);
|
||||
|
||||
TESS_API TessCubeRecoContext*
|
||||
TESS_CALL TessBaseAPIGetCubeRecoContext(const TessBaseAPI* handle);
|
||||
#endif
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetMinOrientationMargin(TessBaseAPI* handle, double margin);
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API void TESS_CALL TessBaseGetBlockTextOrientations(TessBaseAPI* handle, int** block_orientation, bool** vertical_writing);
|
||||
|
||||
TESS_API BLOCK_LIST*
|
||||
TESS_CALL TessBaseAPIFindLinesCreateBlockList(TessBaseAPI* handle);
|
||||
#endif
|
||||
|
||||
/* Page iterator */
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorDelete(TessPageIterator* handle);
|
||||
TESS_API TessPageIterator*
|
||||
TESS_CALL TessPageIteratorCopy(const TessPageIterator* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorBegin(TessPageIterator* handle);
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorNext(TessPageIterator* handle, TessPageIteratorLevel level);
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorIsAtBeginningOf(const TessPageIterator* handle, TessPageIteratorLevel level);
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorIsAtFinalElement(const TessPageIterator* handle, TessPageIteratorLevel level,
|
||||
TessPageIteratorLevel element);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorBoundingBox(const TessPageIterator* handle, TessPageIteratorLevel level,
|
||||
int* left, int* top, int* right, int* bottom);
|
||||
TESS_API TessPolyBlockType
|
||||
TESS_CALL TessPageIteratorBlockType(const TessPageIterator* handle);
|
||||
|
||||
TESS_API PIX* TESS_CALL TessPageIteratorGetBinaryImage(const TessPageIterator* handle, TessPageIteratorLevel level);
|
||||
TESS_API PIX* TESS_CALL TessPageIteratorGetImage(const TessPageIterator* handle, TessPageIteratorLevel level, int padding,
|
||||
int* left, int* top);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorBaseline(const TessPageIterator* handle, TessPageIteratorLevel level,
|
||||
int* x1, int* y1, int* x2, int* y2);
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorOrientation(TessPageIterator* handle, TessOrientation *orientation,
|
||||
TessWritingDirection *writing_direction, TessTextlineOrder *textline_order,
|
||||
float *deskew_angle);
|
||||
|
||||
/* Result iterator */
|
||||
|
||||
TESS_API void TESS_CALL TessResultIteratorDelete(TessResultIterator* handle);
|
||||
TESS_API TessResultIterator*
|
||||
TESS_CALL TessResultIteratorCopy(const TessResultIterator* handle);
|
||||
TESS_API TessPageIterator*
|
||||
TESS_CALL TessResultIteratorGetPageIterator(TessResultIterator* handle);
|
||||
TESS_API const TessPageIterator*
|
||||
TESS_CALL TessResultIteratorGetPageIteratorConst(const TessResultIterator* handle);
|
||||
|
||||
TESS_API char* TESS_CALL TessResultIteratorGetUTF8Text(const TessResultIterator* handle, TessPageIteratorLevel level);
|
||||
TESS_API float TESS_CALL TessResultIteratorConfidence(const TessResultIterator* handle, TessPageIteratorLevel level);
|
||||
|
||||
TESS_API const char*
|
||||
TESS_CALL TessResultIteratorWordFontAttributes(const TessResultIterator* handle, BOOL* is_bold, BOOL* is_italic,
|
||||
BOOL* is_underlined, BOOL* is_monospace, BOOL* is_serif,
|
||||
BOOL* is_smallcaps, int* pointsize, int* font_id);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessResultIteratorWordIsFromDictionary(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL TessResultIteratorWordIsNumeric(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsSuperscript(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsSubscript(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsDropcap(const TessResultIterator* handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TESSERACT_API_CAPI_H__ */
|
||||
@@ -1,105 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: errcode.h (Formerly error.h)
|
||||
* Description: Header file for generic error handler class
|
||||
* Author: Ray Smith
|
||||
* Created: Tue May 1 16:23:36 BST 1990
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ERRCODE_H
|
||||
#define ERRCODE_H
|
||||
|
||||
#include "host.h"
|
||||
|
||||
/*Control parameters for error()*/
|
||||
enum TessErrorLogCode {
|
||||
DBG = -1, /*log without alert */
|
||||
TESSLOG = 0, /*alert user */
|
||||
TESSEXIT = 1, /*exit after erro */
|
||||
ABORT = 2 /*abort after error */
|
||||
};
|
||||
|
||||
/* Explicit Error Abort codes */
|
||||
#define NO_ABORT_CODE 0
|
||||
#define LIST_ABORT 1
|
||||
#define MEMORY_ABORT 2
|
||||
#define FILE_ABORT 3
|
||||
|
||||
/* Location of code at error codes Reserve 0..2 (status codes 0..23 for UNLV)*/
|
||||
#define LOC_UNUSED0 0
|
||||
#define LOC_UNUSED1 1
|
||||
#define LOC_UNUSED2 2
|
||||
#define LOC_INIT 3
|
||||
#define LOC_EDGE_PROG 4
|
||||
#define LOC_TEXT_ORD_ROWS 5
|
||||
#define LOC_TEXT_ORD_WORDS 6
|
||||
#define LOC_PASS1 7
|
||||
#define LOC_PASS2 8
|
||||
/* Reserve up to 8..13 for adding subloc 0/3 plus subsubloc 0/1/2 */
|
||||
#define LOC_FUZZY_SPACE 14
|
||||
/* Reserve up to 14..20 for adding subloc 0/3 plus subsubloc 0/1/2 */
|
||||
#define LOC_MM_ADAPT 21
|
||||
#define LOC_DOC_BLK_REJ 22
|
||||
#define LOC_WRITE_RESULTS 23
|
||||
#define LOC_ADAPTIVE 24
|
||||
/* DONT DEFINE ANY LOCATION > 31 !!! */
|
||||
|
||||
/* Sub locatation determines whether pass2 was in normal mode or fix xht mode*/
|
||||
#define SUBLOC_NORM 0
|
||||
#define SUBLOC_FIX_XHT 3
|
||||
|
||||
/* Sub Sub locatation determines whether match_word_pass2 was in Tess
|
||||
matcher, NN matcher or somewhere else */
|
||||
|
||||
#define SUBSUBLOC_OTHER 0
|
||||
#define SUBSUBLOC_TESS 1
|
||||
#define SUBSUBLOC_NN 2
|
||||
|
||||
class TESS_API ERRCODE { // error handler class
|
||||
const char *message; // error message
|
||||
public:
|
||||
void error( // error print function
|
||||
const char *caller, // function location
|
||||
TessErrorLogCode action, // action to take
|
||||
const char *format, ... // fprintf format
|
||||
) const;
|
||||
ERRCODE(const char *string) {
|
||||
message = string;
|
||||
} // initialize with string
|
||||
};
|
||||
|
||||
const ERRCODE ASSERT_FAILED = "Assert failed";
|
||||
|
||||
#define ASSERT_HOST(x) if (!(x)) \
|
||||
{ \
|
||||
ASSERT_FAILED.error(#x,ABORT,"in file %s, line %d", \
|
||||
__FILE__,__LINE__); \
|
||||
}
|
||||
|
||||
void signal_exit( //
|
||||
int signal_code //Signal which
|
||||
);
|
||||
extern "C"
|
||||
{
|
||||
void err_exit();
|
||||
//The real signal
|
||||
void signal_termination_handler(int sig);
|
||||
};
|
||||
|
||||
void set_global_loc_code(int loc_code);
|
||||
|
||||
void set_global_subloc_code(int loc_code);
|
||||
|
||||
void set_global_subsubloc_code(int loc_code);
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: fileerr.h (Formerly filerr.h)
|
||||
* Description: Errors for file utilities.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Aug 14 15:45:16 BST 1990
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef FILEERR_H
|
||||
#define FILEERR_H
|
||||
|
||||
#include "errcode.h"
|
||||
|
||||
const ERRCODE CANTOPENFILE = "Can't open file";
|
||||
const ERRCODE CANTCREATEFILE = "Can't create file";
|
||||
const ERRCODE CANTMAKEPIPE = "Can't create pipe";
|
||||
const ERRCODE CANTCONNECTPIPE = "Can't reconnect pipes to stdin/stdout";
|
||||
const ERRCODE READFAILED = "Read of file failed";
|
||||
const ERRCODE WRITEFAILED = "Write of file failed";
|
||||
const ERRCODE SELECTFAILED = "Select failed";
|
||||
|
||||
const ERRCODE EXECFAILED = "Could not exec new process";
|
||||
#endif
|
||||
@@ -1,807 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: genericvector.h
|
||||
// Description: Generic vector class
|
||||
// Author: Daria Antonova
|
||||
// Created: Mon Jun 23 11:26:43 PDT 2008
|
||||
//
|
||||
// (C) Copyright 2007, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef TESSERACT_CCUTIL_GENERICVECTOR_H_
|
||||
#define TESSERACT_CCUTIL_GENERICVECTOR_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tesscallback.h"
|
||||
#include "errcode.h"
|
||||
#include "helpers.h"
|
||||
#include "ndminx.h"
|
||||
|
||||
// Use PointerVector<T> below in preference to GenericVector<T*>, as that
|
||||
// provides automatic deletion of pointers, [De]Serialize that works, and
|
||||
// sort that works.
|
||||
template <typename T>
|
||||
class GenericVector {
|
||||
public:
|
||||
GenericVector() { this->init(kDefaultVectorSize); }
|
||||
explicit GenericVector(int size) { this->init(size); }
|
||||
|
||||
// Copy
|
||||
GenericVector(const GenericVector& other) {
|
||||
this->init(other.size());
|
||||
this->operator+=(other);
|
||||
}
|
||||
GenericVector<T> &operator+=(const GenericVector& other);
|
||||
GenericVector<T> &operator=(const GenericVector& other);
|
||||
|
||||
virtual ~GenericVector();
|
||||
|
||||
// Reserve some memory.
|
||||
void reserve(int size);
|
||||
// Double the size of the internal array.
|
||||
void double_the_size();
|
||||
|
||||
// Resizes to size and sets all values to t.
|
||||
void init_to_size(int size, T t);
|
||||
|
||||
// Return the size used.
|
||||
int size() const {
|
||||
return size_used_;
|
||||
}
|
||||
|
||||
int length() const {
|
||||
return size_used_;
|
||||
}
|
||||
|
||||
// Return true if empty.
|
||||
bool empty() const {
|
||||
return size_used_ == 0;
|
||||
}
|
||||
|
||||
// Return the object from an index.
|
||||
T &get(int index) const;
|
||||
T &back() const;
|
||||
T &operator[](int index) const;
|
||||
|
||||
// Return the index of the T object.
|
||||
// This method NEEDS a compare_callback to be passed to
|
||||
// set_compare_callback.
|
||||
int get_index(T object) const;
|
||||
|
||||
// Return true if T is in the array
|
||||
bool contains(T object) const;
|
||||
|
||||
// Return true if the index is valid
|
||||
T contains_index(int index) const;
|
||||
|
||||
// Push an element in the end of the array
|
||||
int push_back(T object);
|
||||
void operator+=(T t);
|
||||
|
||||
// Push an element in the end of the array if the same
|
||||
// element is not already contained in the array.
|
||||
int push_back_new(T object);
|
||||
|
||||
// Push an element in the front of the array
|
||||
// Note: This function is O(n)
|
||||
int push_front(T object);
|
||||
|
||||
// Set the value at the given index
|
||||
void set(T t, int index);
|
||||
|
||||
// Insert t at the given index, push other elements to the right.
|
||||
void insert(T t, int index);
|
||||
|
||||
// Removes an element at the given index and
|
||||
// shifts the remaining elements to the left.
|
||||
virtual void remove(int index);
|
||||
|
||||
// Truncates the array to the given size by removing the end.
|
||||
// If the current size is less, the array is not expanded.
|
||||
virtual void truncate(int size) {
|
||||
if (size < size_used_)
|
||||
size_used_ = size;
|
||||
}
|
||||
|
||||
// Add a callback to be called to delete the elements when the array took
|
||||
// their ownership.
|
||||
void set_clear_callback(TessCallback1<T>* cb);
|
||||
|
||||
// Add a callback to be called to compare the elements when needed (contains,
|
||||
// get_id, ...)
|
||||
void set_compare_callback(TessResultCallback2<bool, T const &, T const &>* cb);
|
||||
|
||||
// Clear the array, calling the clear callback function if any.
|
||||
// All the owned callbacks are also deleted.
|
||||
// If you don't want the callbacks to be deleted, before calling clear, set
|
||||
// the callback to NULL.
|
||||
virtual void clear();
|
||||
|
||||
// Delete objects pointed to by data_[i]
|
||||
void delete_data_pointers();
|
||||
|
||||
// This method clears the current object, then, does a shallow copy of
|
||||
// its argument, and finally invalidates its argument.
|
||||
// Callbacks are moved to the current object;
|
||||
void move(GenericVector<T>* from);
|
||||
|
||||
// Read/Write the array to a file. This does _NOT_ read/write the callbacks.
|
||||
// The callback given must be permanent since they will be called more than
|
||||
// once. The given callback will be deleted at the end.
|
||||
// If the callbacks are NULL, then the data is simply read/written using
|
||||
// fread (and swapping)/fwrite.
|
||||
// Returns false on error or if the callback returns false.
|
||||
// DEPRECATED. Use [De]Serialize[Classes] instead.
|
||||
bool write(FILE* f, TessResultCallback2<bool, FILE*, T const &>* cb) const;
|
||||
bool read(FILE* f, TessResultCallback3<bool, FILE*, T*, bool>* cb, bool swap);
|
||||
// Writes a vector of simple types to the given file. Assumes that bitwise
|
||||
// read/write of T will work. Returns false in case of error.
|
||||
virtual bool Serialize(FILE* fp) const;
|
||||
// Reads a vector of simple types from the given file. Assumes that bitwise
|
||||
// read/write will work with ReverseN according to sizeof(T).
|
||||
// Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
virtual bool DeSerialize(bool swap, FILE* fp);
|
||||
// Writes a vector of classes to the given file. Assumes the existence of
|
||||
// bool T::Serialize(FILE* fp) const that returns false in case of error.
|
||||
// Returns false in case of error.
|
||||
bool SerializeClasses(FILE* fp) const;
|
||||
// Reads a vector of classes from the given file. Assumes the existence of
|
||||
// bool T::Deserialize(bool swap, FILE* fp) that returns false in case of
|
||||
// error. Also needs T::T() and T::T(constT&), as init_to_size is used in
|
||||
// this function. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool DeSerializeClasses(bool swap, FILE* fp);
|
||||
|
||||
// Allocates a new array of double the current_size, copies over the
|
||||
// information from data to the new location, deletes data and returns
|
||||
// the pointed to the new larger array.
|
||||
// This function uses memcpy to copy the data, instead of invoking
|
||||
// operator=() for each element like double_the_size() does.
|
||||
static T *double_the_size_memcpy(int current_size, T *data) {
|
||||
T *data_new = new T[current_size * 2];
|
||||
memcpy(data_new, data, sizeof(T) * current_size);
|
||||
delete[] data;
|
||||
return data_new;
|
||||
}
|
||||
|
||||
// Sorts the members of this vector using the less than comparator (cmp_lt),
|
||||
// which compares the values. Useful for GenericVectors to primitive types.
|
||||
// Will not work so great for pointers (unless you just want to sort some
|
||||
// pointers). You need to provide a specialization to sort_cmp to use
|
||||
// your type.
|
||||
void sort();
|
||||
|
||||
// Sort the array into the order defined by the qsort function comparator.
|
||||
// The comparator function is as defined by qsort, ie. it receives pointers
|
||||
// to two Ts and returns negative if the first element is to appear earlier
|
||||
// in the result and positive if it is to appear later, with 0 for equal.
|
||||
void sort(int (*comparator)(const void*, const void*)) {
|
||||
qsort(data_, size_used_, sizeof(*data_), comparator);
|
||||
}
|
||||
|
||||
// Searches the array (assuming sorted in ascending order, using sort()) for
|
||||
// an element equal to target and returns true if it is present.
|
||||
// Use binary_search to get the index of target, or its nearest candidate.
|
||||
bool bool_binary_search(const T& target) const {
|
||||
int index = binary_search(target);
|
||||
if (index >= size_used_)
|
||||
return false;
|
||||
return data_[index] == target;
|
||||
}
|
||||
// Searches the array (assuming sorted in ascending order, using sort()) for
|
||||
// an element equal to target and returns the index of the best candidate.
|
||||
// The return value is conceptually the largest index i such that
|
||||
// data_[i] <= target or 0 if target < the whole vector.
|
||||
// NOTE that this function uses operator> so really the return value is
|
||||
// the largest index i such that data_[i] > target is false.
|
||||
int binary_search(const T& target) const {
|
||||
int bottom = 0;
|
||||
int top = size_used_;
|
||||
do {
|
||||
int middle = (bottom + top) / 2;
|
||||
if (data_[middle] > target)
|
||||
top = middle;
|
||||
else
|
||||
bottom = middle;
|
||||
}
|
||||
while (top - bottom > 1);
|
||||
return bottom;
|
||||
}
|
||||
|
||||
// Compact the vector by deleting elements using operator!= on basic types.
|
||||
// The vector must be sorted.
|
||||
void compact_sorted() {
|
||||
if (size_used_ == 0)
|
||||
return;
|
||||
|
||||
// First element is in no matter what, hence the i = 1.
|
||||
int last_write = 0;
|
||||
for (int i = 1; i < size_used_; ++i) {
|
||||
// Finds next unique item and writes it.
|
||||
if (data_[last_write] != data_[i])
|
||||
data_[++last_write] = data_[i];
|
||||
}
|
||||
// last_write is the index of a valid data cell, so add 1.
|
||||
size_used_ = last_write + 1;
|
||||
}
|
||||
|
||||
// Compact the vector by deleting elements for which delete_cb returns
|
||||
// true. delete_cb is a permanent callback and will be deleted.
|
||||
void compact(TessResultCallback1<bool, int>* delete_cb) {
|
||||
int new_size = 0;
|
||||
int old_index = 0;
|
||||
// Until the callback returns true, the elements stay the same.
|
||||
while (old_index < size_used_ && !delete_cb->Run(old_index++))
|
||||
++new_size;
|
||||
// Now just copy anything else that gets false from delete_cb.
|
||||
for (; old_index < size_used_; ++old_index) {
|
||||
if (!delete_cb->Run(old_index)) {
|
||||
data_[new_size++] = data_[old_index];
|
||||
}
|
||||
}
|
||||
size_used_ = new_size;
|
||||
delete delete_cb;
|
||||
}
|
||||
|
||||
T dot_product(const GenericVector<T>& other) const {
|
||||
T result = static_cast<T>(0);
|
||||
for (int i = MIN(size_used_, other.size_used_) - 1; i >= 0; --i)
|
||||
result += data_[i] * other.data_[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// Init the object, allocating size memory.
|
||||
void init(int size);
|
||||
|
||||
// We are assuming that the object generally placed in thie
|
||||
// vector are small enough that for efficiency it makes sence
|
||||
// to start with a larger initial size.
|
||||
static const int kDefaultVectorSize = 4;
|
||||
inT32 size_used_;
|
||||
inT32 size_reserved_;
|
||||
T* data_;
|
||||
TessCallback1<T>* clear_cb_;
|
||||
// Mutable because Run method is not const
|
||||
mutable TessResultCallback2<bool, T const &, T const &>* compare_cb_;
|
||||
};
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
template <typename T>
|
||||
bool cmp_eq(T const & t1, T const & t2) {
|
||||
return t1 == t2;
|
||||
}
|
||||
|
||||
// Used by sort()
|
||||
// return < 0 if t1 < t2
|
||||
// return 0 if t1 == t2
|
||||
// return > 0 if t1 > t2
|
||||
template <typename T>
|
||||
int sort_cmp(const void* t1, const void* t2) {
|
||||
const T* a = static_cast<const T *> (t1);
|
||||
const T* b = static_cast<const T *> (t2);
|
||||
if (*a < *b) {
|
||||
return -1;
|
||||
} else if (*b < *a) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Used by PointerVector::sort()
|
||||
// return < 0 if t1 < t2
|
||||
// return 0 if t1 == t2
|
||||
// return > 0 if t1 > t2
|
||||
template <typename T>
|
||||
int sort_ptr_cmp(const void* t1, const void* t2) {
|
||||
const T* a = *reinterpret_cast<T * const *>(t1);
|
||||
const T* b = *reinterpret_cast<T * const *>(t2);
|
||||
if (*a < *b) {
|
||||
return -1;
|
||||
} else if (*b < *a) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Subclass for a vector of pointers. Use in preference to GenericVector<T*>
|
||||
// as it provides automatic deletion and correct serialization, with the
|
||||
// corollary that all copy operations are deep copies of the pointed-to objects.
|
||||
template<typename T>
|
||||
class PointerVector : public GenericVector<T*> {
|
||||
public:
|
||||
PointerVector() : GenericVector<T*>() { }
|
||||
explicit PointerVector(int size) : GenericVector<T*>(size) { }
|
||||
virtual ~PointerVector() {
|
||||
// Clear must be called here, even though it is called again by the base,
|
||||
// as the base will call the wrong clear.
|
||||
clear();
|
||||
}
|
||||
// Copy must be deep, as the pointers will be automatically deleted on
|
||||
// destruction.
|
||||
PointerVector(const PointerVector& other) {
|
||||
this->init(other.size());
|
||||
this->operator+=(other);
|
||||
}
|
||||
PointerVector<T>& operator+=(const PointerVector& other) {
|
||||
this->reserve(this->size_used_ + other.size_used_);
|
||||
for (int i = 0; i < other.size(); ++i) {
|
||||
this->push_back(new T(*other.data_[i]));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
PointerVector<T>& operator=(const PointerVector& other) {
|
||||
this->truncate(0);
|
||||
this->operator+=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Removes an element at the given index and
|
||||
// shifts the remaining elements to the left.
|
||||
virtual void remove(int index) {
|
||||
delete GenericVector<T*>::data_[index];
|
||||
GenericVector<T*>::remove(index);
|
||||
}
|
||||
|
||||
// Truncates the array to the given size by removing the end.
|
||||
// If the current size is less, the array is not expanded.
|
||||
virtual void truncate(int size) {
|
||||
for (int i = size; i < GenericVector<T*>::size_used_; ++i)
|
||||
delete GenericVector<T*>::data_[i];
|
||||
GenericVector<T*>::truncate(size);
|
||||
}
|
||||
|
||||
// Compact the vector by deleting elements for which delete_cb returns
|
||||
// true. delete_cb is a permanent callback and will be deleted.
|
||||
void compact(TessResultCallback1<bool, const T*>* delete_cb) {
|
||||
int new_size = 0;
|
||||
int old_index = 0;
|
||||
// Until the callback returns true, the elements stay the same.
|
||||
while (old_index < GenericVector<T*>::size_used_ &&
|
||||
!delete_cb->Run(GenericVector<T*>::data_[old_index++]))
|
||||
++new_size;
|
||||
// Now just copy anything else that gets false from delete_cb.
|
||||
for (; old_index < GenericVector<T*>::size_used_; ++old_index) {
|
||||
if (!delete_cb->Run(GenericVector<T*>::data_[old_index])) {
|
||||
GenericVector<T*>::data_[new_size++] =
|
||||
GenericVector<T*>::data_[old_index];
|
||||
} else {
|
||||
delete GenericVector<T*>::data_[old_index];
|
||||
}
|
||||
}
|
||||
GenericVector<T*>::size_used_ = new_size;
|
||||
delete delete_cb;
|
||||
}
|
||||
|
||||
// Clear the array, calling the clear callback function if any.
|
||||
// All the owned callbacks are also deleted.
|
||||
// If you don't want the callbacks to be deleted, before calling clear, set
|
||||
// the callback to NULL.
|
||||
virtual void clear() {
|
||||
GenericVector<T*>::delete_data_pointers();
|
||||
GenericVector<T*>::clear();
|
||||
}
|
||||
|
||||
// Writes a vector of simple types to the given file. Assumes that bitwise
|
||||
// read/write of T will work. Returns false in case of error.
|
||||
virtual bool Serialize(FILE* fp) const {
|
||||
inT32 used = GenericVector<T*>::size_used_;
|
||||
if (fwrite(&used, sizeof(used), 1, fp) != 1) return false;
|
||||
for (int i = 0; i < used; ++i) {
|
||||
inT8 non_null = GenericVector<T*>::data_[i] != NULL;
|
||||
if (fwrite(&non_null, sizeof(non_null), 1, fp) != 1) return false;
|
||||
if (non_null && !GenericVector<T*>::data_[i]->Serialize(fp)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Reads a vector of simple types from the given file. Assumes that bitwise
|
||||
// read/write will work with ReverseN according to sizeof(T).
|
||||
// Also needs T::T(), as new T is used in this function.
|
||||
// Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
virtual bool DeSerialize(bool swap, FILE* fp) {
|
||||
inT32 reserved;
|
||||
if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
|
||||
if (swap) Reverse32(&reserved);
|
||||
GenericVector<T*>::reserve(reserved);
|
||||
for (int i = 0; i < reserved; ++i) {
|
||||
inT8 non_null;
|
||||
if (fread(&non_null, sizeof(non_null), 1, fp) != 1) return false;
|
||||
T* item = NULL;
|
||||
if (non_null) {
|
||||
item = new T;
|
||||
if (!item->DeSerialize(swap, fp)) return false;
|
||||
}
|
||||
this->push_back(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sorts the items pointed to by the members of this vector using
|
||||
// t::operator<().
|
||||
void sort() {
|
||||
sort(&sort_ptr_cmp<T>);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tesseract
|
||||
|
||||
// A useful vector that uses operator== to do comparisons.
|
||||
template <typename T>
|
||||
class GenericVectorEqEq : public GenericVector<T> {
|
||||
public:
|
||||
GenericVectorEqEq() {
|
||||
GenericVector<T>::set_compare_callback(
|
||||
NewPermanentTessCallback(tesseract::cmp_eq<T>));
|
||||
}
|
||||
GenericVectorEqEq(int size) : GenericVector<T>(size) {
|
||||
GenericVector<T>::set_compare_callback(
|
||||
NewPermanentTessCallback(tesseract::cmp_eq<T>));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void GenericVector<T>::init(int size) {
|
||||
size_used_ = 0;
|
||||
size_reserved_ = 0;
|
||||
data_ = 0;
|
||||
clear_cb_ = 0;
|
||||
compare_cb_ = 0;
|
||||
reserve(size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GenericVector<T>::~GenericVector() {
|
||||
clear();
|
||||
}
|
||||
|
||||
// Reserve some memory. If the internal array contains elements, they are
|
||||
// copied.
|
||||
template <typename T>
|
||||
void GenericVector<T>::reserve(int size) {
|
||||
if (size_reserved_ >= size || size <= 0)
|
||||
return;
|
||||
T* new_array = new T[size];
|
||||
for (int i = 0; i < size_used_; ++i)
|
||||
new_array[i] = data_[i];
|
||||
if (data_ != NULL) delete[] data_;
|
||||
data_ = new_array;
|
||||
size_reserved_ = size;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void GenericVector<T>::double_the_size() {
|
||||
if (size_reserved_ == 0) {
|
||||
reserve(kDefaultVectorSize);
|
||||
}
|
||||
else {
|
||||
reserve(2 * size_reserved_);
|
||||
}
|
||||
}
|
||||
|
||||
// Resizes to size and sets all values to t.
|
||||
template <typename T>
|
||||
void GenericVector<T>::init_to_size(int size, T t) {
|
||||
reserve(size);
|
||||
size_used_ = size;
|
||||
for (int i = 0; i < size; ++i)
|
||||
data_[i] = t;
|
||||
}
|
||||
|
||||
|
||||
// Return the object from an index.
|
||||
template <typename T>
|
||||
T &GenericVector<T>::get(int index) const {
|
||||
ASSERT_HOST(index >= 0 && index < size_used_);
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T &GenericVector<T>::operator[](int index) const {
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T &GenericVector<T>::back() const {
|
||||
ASSERT_HOST(size_used_ > 0);
|
||||
return data_[size_used_ - 1];
|
||||
}
|
||||
|
||||
// Return the object from an index.
|
||||
template <typename T>
|
||||
void GenericVector<T>::set(T t, int index) {
|
||||
ASSERT_HOST(index >= 0 && index < size_used_);
|
||||
data_[index] = t;
|
||||
}
|
||||
|
||||
// Shifts the rest of the elements to the right to make
|
||||
// space for the new elements and inserts the given element
|
||||
// at the specified index.
|
||||
template <typename T>
|
||||
void GenericVector<T>::insert(T t, int index) {
|
||||
ASSERT_HOST(index >= 0 && index < size_used_);
|
||||
if (size_reserved_ == size_used_)
|
||||
double_the_size();
|
||||
for (int i = size_used_; i > index; --i) {
|
||||
data_[i] = data_[i-1];
|
||||
}
|
||||
data_[index] = t;
|
||||
size_used_++;
|
||||
}
|
||||
|
||||
// Removes an element at the given index and
|
||||
// shifts the remaining elements to the left.
|
||||
template <typename T>
|
||||
void GenericVector<T>::remove(int index) {
|
||||
ASSERT_HOST(index >= 0 && index < size_used_);
|
||||
for (int i = index; i < size_used_ - 1; ++i) {
|
||||
data_[i] = data_[i+1];
|
||||
}
|
||||
size_used_--;
|
||||
}
|
||||
|
||||
// Return true if the index is valindex
|
||||
template <typename T>
|
||||
T GenericVector<T>::contains_index(int index) const {
|
||||
return index >= 0 && index < size_used_;
|
||||
}
|
||||
|
||||
// Return the index of the T object.
|
||||
template <typename T>
|
||||
int GenericVector<T>::get_index(T object) const {
|
||||
for (int i = 0; i < size_used_; ++i) {
|
||||
ASSERT_HOST(compare_cb_ != NULL);
|
||||
if (compare_cb_->Run(object, data_[i]))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return true if T is in the array
|
||||
template <typename T>
|
||||
bool GenericVector<T>::contains(T object) const {
|
||||
return get_index(object) != -1;
|
||||
}
|
||||
|
||||
// Add an element in the array
|
||||
template <typename T>
|
||||
int GenericVector<T>::push_back(T object) {
|
||||
int index = 0;
|
||||
if (size_used_ == size_reserved_)
|
||||
double_the_size();
|
||||
index = size_used_++;
|
||||
data_[index] = object;
|
||||
return index;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int GenericVector<T>::push_back_new(T object) {
|
||||
int index = get_index(object);
|
||||
if (index >= 0)
|
||||
return index;
|
||||
return push_back(object);
|
||||
}
|
||||
|
||||
// Add an element in the array (front)
|
||||
template <typename T>
|
||||
int GenericVector<T>::push_front(T object) {
|
||||
if (size_used_ == size_reserved_)
|
||||
double_the_size();
|
||||
for (int i = size_used_; i > 0; --i)
|
||||
data_[i] = data_[i-1];
|
||||
data_[0] = object;
|
||||
++size_used_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void GenericVector<T>::operator+=(T t) {
|
||||
push_back(t);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GenericVector<T> &GenericVector<T>::operator+=(const GenericVector& other) {
|
||||
this->reserve(size_used_ + other.size_used_);
|
||||
for (int i = 0; i < other.size(); ++i) {
|
||||
this->operator+=(other.data_[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GenericVector<T> &GenericVector<T>::operator=(const GenericVector& other) {
|
||||
this->truncate(0);
|
||||
this->operator+=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Add a callback to be called to delete the elements when the array took
|
||||
// their ownership.
|
||||
template <typename T>
|
||||
void GenericVector<T>::set_clear_callback(TessCallback1<T>* cb) {
|
||||
clear_cb_ = cb;
|
||||
}
|
||||
|
||||
// Add a callback to be called to delete the elements when the array took
|
||||
// their ownership.
|
||||
template <typename T>
|
||||
void GenericVector<T>::set_compare_callback(TessResultCallback2<bool, T const &, T const &>* cb) {
|
||||
compare_cb_ = cb;
|
||||
}
|
||||
|
||||
// Clear the array, calling the callback function if any.
|
||||
template <typename T>
|
||||
void GenericVector<T>::clear() {
|
||||
if (size_reserved_ > 0) {
|
||||
if (clear_cb_ != NULL)
|
||||
for (int i = 0; i < size_used_; ++i)
|
||||
clear_cb_->Run(data_[i]);
|
||||
delete[] data_;
|
||||
data_ = NULL;
|
||||
size_used_ = 0;
|
||||
size_reserved_ = 0;
|
||||
}
|
||||
if (clear_cb_ != NULL) {
|
||||
delete clear_cb_;
|
||||
clear_cb_ = NULL;
|
||||
}
|
||||
if (compare_cb_ != NULL) {
|
||||
delete compare_cb_;
|
||||
compare_cb_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void GenericVector<T>::delete_data_pointers() {
|
||||
for (int i = 0; i < size_used_; ++i)
|
||||
if (data_[i]) {
|
||||
delete data_[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool GenericVector<T>::write(
|
||||
FILE* f, TessResultCallback2<bool, FILE*, T const &>* cb) const {
|
||||
if (fwrite(&size_reserved_, sizeof(size_reserved_), 1, f) != 1) return false;
|
||||
if (fwrite(&size_used_, sizeof(size_used_), 1, f) != 1) return false;
|
||||
if (cb != NULL) {
|
||||
for (int i = 0; i < size_used_; ++i) {
|
||||
if (!cb->Run(f, data_[i])) {
|
||||
delete cb;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
delete cb;
|
||||
} else {
|
||||
if (fwrite(data_, sizeof(T), size_used_, f) != size_used_) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool GenericVector<T>::read(FILE* f,
|
||||
TessResultCallback3<bool, FILE*, T*, bool>* cb,
|
||||
bool swap) {
|
||||
inT32 reserved;
|
||||
if (fread(&reserved, sizeof(reserved), 1, f) != 1) return false;
|
||||
if (swap) Reverse32(&reserved);
|
||||
reserve(reserved);
|
||||
if (fread(&size_used_, sizeof(size_used_), 1, f) != 1) return false;
|
||||
if (swap) Reverse32(&size_used_);
|
||||
if (cb != NULL) {
|
||||
for (int i = 0; i < size_used_; ++i) {
|
||||
if (!cb->Run(f, data_ + i, swap)) {
|
||||
delete cb;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
delete cb;
|
||||
} else {
|
||||
if (fread(data_, sizeof(T), size_used_, f) != size_used_) return false;
|
||||
if (swap) {
|
||||
for (int i = 0; i < size_used_; ++i)
|
||||
ReverseN(&data_[i], sizeof(T));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Writes a vector of simple types to the given file. Assumes that bitwise
|
||||
// read/write of T will work. Returns false in case of error.
|
||||
template <typename T>
|
||||
bool GenericVector<T>::Serialize(FILE* fp) const {
|
||||
if (fwrite(&size_used_, sizeof(size_used_), 1, fp) != 1) return false;
|
||||
if (fwrite(data_, sizeof(*data_), size_used_, fp) != size_used_) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reads a vector of simple types from the given file. Assumes that bitwise
|
||||
// read/write will work with ReverseN according to sizeof(T).
|
||||
// Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
template <typename T>
|
||||
bool GenericVector<T>::DeSerialize(bool swap, FILE* fp) {
|
||||
inT32 reserved;
|
||||
if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
|
||||
if (swap) Reverse32(&reserved);
|
||||
reserve(reserved);
|
||||
size_used_ = reserved;
|
||||
if (fread(data_, sizeof(T), size_used_, fp) != size_used_) return false;
|
||||
if (swap) {
|
||||
for (int i = 0; i < size_used_; ++i)
|
||||
ReverseN(&data_[i], sizeof(data_[i]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Writes a vector of classes to the given file. Assumes the existence of
|
||||
// bool T::Serialize(FILE* fp) const that returns false in case of error.
|
||||
// Returns false in case of error.
|
||||
template <typename T>
|
||||
bool GenericVector<T>::SerializeClasses(FILE* fp) const {
|
||||
if (fwrite(&size_used_, sizeof(size_used_), 1, fp) != 1) return false;
|
||||
for (int i = 0; i < size_used_; ++i) {
|
||||
if (!data_[i].Serialize(fp)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reads a vector of classes from the given file. Assumes the existence of
|
||||
// bool T::Deserialize(bool swap, FILE* fp) that returns false in case of
|
||||
// error. Alse needs T::T() and T::T(constT&), as init_to_size is used in
|
||||
// this function. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
template <typename T>
|
||||
bool GenericVector<T>::DeSerializeClasses(bool swap, FILE* fp) {
|
||||
uinT32 reserved;
|
||||
if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
|
||||
if (swap) Reverse32(&reserved);
|
||||
T empty;
|
||||
init_to_size(reserved, empty);
|
||||
for (int i = 0; i < reserved; ++i) {
|
||||
if (!data_[i].DeSerialize(swap, fp)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// This method clear the current object, then, does a shallow copy of
|
||||
// its argument, and finally invalidates its argument.
|
||||
template <typename T>
|
||||
void GenericVector<T>::move(GenericVector<T>* from) {
|
||||
this->clear();
|
||||
this->data_ = from->data_;
|
||||
this->size_reserved_ = from->size_reserved_;
|
||||
this->size_used_ = from->size_used_;
|
||||
this->compare_cb_ = from->compare_cb_;
|
||||
this->clear_cb_ = from->clear_cb_;
|
||||
from->data_ = NULL;
|
||||
from->clear_cb_ = NULL;
|
||||
from->compare_cb_ = NULL;
|
||||
from->size_used_ = 0;
|
||||
from->size_reserved_ = 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void GenericVector<T>::sort() {
|
||||
sort(&tesseract::sort_cmp<T>);
|
||||
}
|
||||
|
||||
#endif // TESSERACT_CCUTIL_GENERICVECTOR_H_
|
||||
@@ -1,152 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: helpers.h
|
||||
* Description: General utility functions
|
||||
* Author: Daria Antonova
|
||||
* Created: Wed Apr 8 14:37:00 2009
|
||||
* Language: C++
|
||||
* Package: N/A
|
||||
* Status: Reusable Software Component
|
||||
*
|
||||
* (c) Copyright 2009, Google Inc.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_HELPERS_H_
|
||||
#define TESSERACT_CCUTIL_HELPERS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// Remove newline (if any) at the end of the string.
|
||||
inline void chomp_string(char *str) {
|
||||
int last_index = strlen(str) - 1;
|
||||
while (last_index >= 0 &&
|
||||
(str[last_index] == '\n' || str[last_index] == '\r')) {
|
||||
str[last_index--] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// Advance the current pointer of the file if it points to a newline character.
|
||||
inline void SkipNewline(FILE *file) {
|
||||
if (fgetc(file) != '\n') fseek(file, -1, SEEK_CUR);
|
||||
}
|
||||
|
||||
// qsort function to sort 2 floats.
|
||||
inline int sort_floats(const void *arg1, const void *arg2) {
|
||||
float diff = *((float *) arg1) - *((float *) arg2);
|
||||
if (diff > 0) {
|
||||
return 1;
|
||||
} else if (diff < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// return the smallest multiple of block_size greater than or equal to n.
|
||||
inline int RoundUp(int n, int block_size) {
|
||||
return block_size * ((n + block_size - 1) / block_size);
|
||||
}
|
||||
|
||||
// Clip a numeric value to the interval [lower_bound, upper_bound].
|
||||
template<typename T>
|
||||
inline T ClipToRange(const T& x, const T& lower_bound, const T& upper_bound) {
|
||||
if (x < lower_bound)
|
||||
return lower_bound;
|
||||
if (x > upper_bound)
|
||||
return upper_bound;
|
||||
return x;
|
||||
}
|
||||
|
||||
// Extend the range [lower_bound, upper_bound] to include x.
|
||||
template<typename T1, typename T2>
|
||||
inline void UpdateRange(const T1& x, T2* lower_bound, T2* upper_bound) {
|
||||
if (x < *lower_bound)
|
||||
*lower_bound = x;
|
||||
if (x > *upper_bound)
|
||||
*upper_bound = x;
|
||||
}
|
||||
|
||||
// Decrease lower_bound to be <= x_lo AND increase upper_bound to be >= x_hi.
|
||||
template<typename T1, typename T2>
|
||||
inline void UpdateRange(const T1& x_lo, const T1& x_hi,
|
||||
T2* lower_bound, T2* upper_bound) {
|
||||
if (x_lo < *lower_bound)
|
||||
*lower_bound = x_lo;
|
||||
if (x_hi > *upper_bound)
|
||||
*upper_bound = x_hi;
|
||||
}
|
||||
|
||||
// Intersect the range [*lower2, *upper2] with the range [lower1, upper1],
|
||||
// putting the result back in [*lower2, *upper2].
|
||||
// If non-intersecting ranges are given, we end up with *lower2 > *upper2.
|
||||
template<typename T>
|
||||
inline void IntersectRange(const T& lower1, const T& upper1,
|
||||
T* lower2, T* upper2) {
|
||||
if (lower1 > *lower2)
|
||||
*lower2 = lower1;
|
||||
if (upper1 < *upper2)
|
||||
*upper2 = upper1;
|
||||
}
|
||||
|
||||
// Proper modulo arithmetic operator. Returns a mod b that works for -ve a.
|
||||
// For any integer a and positive b, returns r : 0<=r<b and a=n*b + r for
|
||||
// some integer n.
|
||||
inline int Modulo(int a, int b) {
|
||||
return (a % b + b) % b;
|
||||
}
|
||||
|
||||
// Integer division operator with rounding that works for negative input.
|
||||
// Returns a divided by b, rounded to the nearest integer, without double
|
||||
// counting at 0. With simple rounding 1/3 = 0, 0/3 = 0 -1/3 = 0, -2/3 = 0,
|
||||
// -3/3 = 0 and -4/3 = -1.
|
||||
// I want 1/3 = 0, 0/3 = 0, -1/3 = 0, -2/3 = -1, -3/3 = -1 and -4/3 = -1.
|
||||
inline int DivRounded(int a, int b) {
|
||||
if (b < 0) return -DivRounded(a, -b);
|
||||
return a >= 0 ? (a + b / 2) / b : (a - b / 2) / b;
|
||||
}
|
||||
|
||||
// Return a double cast to int with rounding.
|
||||
inline int IntCastRounded(double x) {
|
||||
return x >= 0.0 ? static_cast<int>(x + 0.5) : -static_cast<int>(-x + 0.5);
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a n byte quantity for big/little-endian switch.
|
||||
inline void ReverseN(void* ptr, int num_bytes) {
|
||||
char *cptr = reinterpret_cast<char *>(ptr);
|
||||
int halfsize = num_bytes / 2;
|
||||
for (int i = 0; i < halfsize; ++i) {
|
||||
char tmp = cptr[i];
|
||||
cptr[i] = cptr[num_bytes - 1 - i];
|
||||
cptr[num_bytes - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a 16 bit quantity for big/little-endian switch.
|
||||
inline void Reverse16(void *ptr) {
|
||||
ReverseN(ptr, 2);
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a 32 bit quantity for big/little-endian switch.
|
||||
inline void Reverse32(void *ptr) {
|
||||
ReverseN(ptr, 4);
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a 64 bit quantity for big/little-endian switch.
|
||||
inline void Reverse64(void* ptr) {
|
||||
ReverseN(ptr, 8);
|
||||
}
|
||||
|
||||
|
||||
#endif // TESSERACT_CCUTIL_HELPERS_H_
|
||||
@@ -1,153 +0,0 @@
|
||||
/******************************************************************************
|
||||
** Filename: Host.h
|
||||
** Purpose: This is the system independent typedefs and defines
|
||||
** Author: MN, JG, MD
|
||||
** Version: 5.4.1
|
||||
** History: 11/7/94 MCD received the modification that Lennart made
|
||||
** to port to 32 bit world and modify this file so that it
|
||||
** will be shared between platform.
|
||||
** 11/9/94 MCD Make MSW32 subset of MSW. Now MSW means
|
||||
** MicroSoft Window and MSW32 means the 32 bit worlds
|
||||
** of MicroSoft Window. Therefore you want the environment
|
||||
** to be MicroSoft Window and in the 32 bit world -
|
||||
** _WIN32 must be defined by your compiler.
|
||||
** 11/30/94 MCD Incorporated comments received for more
|
||||
** readability and the missing typedef for FLOAT.
|
||||
** 12/1/94 MCD Added PFVOID typedef
|
||||
** 5/1/95 MCD. Made many changes based on the inputs.
|
||||
** Changes:
|
||||
** 1) Rearrange the #ifdef so that there're definitions for
|
||||
** particular platforms.
|
||||
** 2) Took out the #define for computer and environment
|
||||
** that developer can uncomment
|
||||
** 3) Added __OLDCODE__ where the defines will be
|
||||
** obsoleted in the next version and advise not to use.
|
||||
** 4) Added the definitions for the following:
|
||||
** FILE_HANDLE, MEMORY_HANDLE, BOOL8,
|
||||
** MAX_INT8, MAX_INT16, MAX_INT32, MAX_UINT8
|
||||
** MAX_UINT16, MAX_UINT32, MAX_FLOAT32
|
||||
** 06/19/96 MCD. Took out MAX_FLOAT32
|
||||
** 07/15/96 MCD. Fixed the comments error
|
||||
** Add back BOOL8.
|
||||
**
|
||||
** (c) Copyright Hewlett-Packard Company, 1988-1996.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __HOST__
|
||||
#define __HOST__
|
||||
|
||||
/******************************************************************************
|
||||
** IMPORTANT!!! **
|
||||
** **
|
||||
** Defines either _WIN32, __MAC__, __UNIX__, __OS2__, __PM__ to
|
||||
** use the specified definitions indicated below in the preprocessor settings. **
|
||||
** **
|
||||
** Also define either __FarProc__ or __FarData__ and __MOTO__ to use the
|
||||
** specified definitions indicated below in the preprocessor settings. **
|
||||
** **
|
||||
** If a preprocessor settings is not allow in the compiler that is being use,
|
||||
** then it is recommended that a "platform.h" is created with the definition
|
||||
** of the computer and/or operating system.
|
||||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
/* _WIN32 */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <winbase.h> // winbase.h contains windows.h
|
||||
#endif
|
||||
|
||||
/********************************************************/
|
||||
/* __MAC__ */
|
||||
#ifdef __MAC__
|
||||
#include <Types.h>
|
||||
/*----------------------------*/
|
||||
/*----------------------------*/
|
||||
#endif
|
||||
/********************************************************/
|
||||
#if defined(__UNIX__) || defined( __DOS__ ) || defined(__OS2__) || defined(__PM__)
|
||||
/*----------------------------*/
|
||||
/* FarProc and FarData */
|
||||
/*----------------------------*/
|
||||
/*----------------------------*/
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
**
|
||||
** Standard GHC Definitions
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef __MOTO__
|
||||
#define __NATIVE__ MOTO
|
||||
#else
|
||||
#define __NATIVE__ INTEL
|
||||
#endif
|
||||
|
||||
//typedef HANDLE FD* PHANDLE;
|
||||
|
||||
// definitions of portable data types (numbers and characters)
|
||||
typedef SIGNED char inT8;
|
||||
typedef unsigned char uinT8;
|
||||
typedef short inT16;
|
||||
typedef unsigned short uinT16;
|
||||
typedef int inT32;
|
||||
typedef unsigned int uinT32;
|
||||
#if (_MSC_VER >= 1200) //%%% vkr for VC 6.0
|
||||
typedef INT64 inT64;
|
||||
typedef UINT64 uinT64;
|
||||
#else
|
||||
typedef long long int inT64;
|
||||
typedef unsigned long long int uinT64;
|
||||
#endif //%%% vkr for VC 6.0
|
||||
typedef float FLOAT32;
|
||||
typedef double FLOAT64;
|
||||
typedef unsigned char BOOL8;
|
||||
|
||||
#define INT32FORMAT "%d"
|
||||
#define INT64FORMAT "%lld"
|
||||
|
||||
#define MAX_INT8 0x7f
|
||||
#define MAX_INT16 0x7fff
|
||||
#define MAX_INT32 0x7fffffff
|
||||
#define MAX_UINT8 0xff
|
||||
#define MAX_UINT16 0xffff
|
||||
#define MAX_UINT32 0xffffffff
|
||||
#define MAX_FLOAT32 ((float)3.40282347e+38)
|
||||
|
||||
#define MIN_INT8 0x80
|
||||
#define MIN_INT16 0x8000
|
||||
#define MIN_INT32 0x80000000
|
||||
#define MIN_UINT8 0x00
|
||||
#define MIN_UINT16 0x0000
|
||||
#define MIN_UINT32 0x00000000
|
||||
#define MIN_FLOAT32 ((float)1.17549435e-38)
|
||||
|
||||
// Defines
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0L
|
||||
#endif
|
||||
|
||||
// Return true if x is within tolerance of y
|
||||
template<class T> bool NearlyEqual(T x, T y, T tolerance) {
|
||||
T diff = x - y;
|
||||
return diff <= tolerance && -diff <= tolerance;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,203 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: ltrresultiterator.h
|
||||
// Description: Iterator for tesseract results in strict left-to-right
|
||||
// order that avoids using tesseract internal data structures.
|
||||
// Author: Ray Smith
|
||||
// Created: Fri Feb 26 11:01:06 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H__
|
||||
#define TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H__
|
||||
|
||||
#include "platform.h"
|
||||
#include "pageiterator.h"
|
||||
#include "unicharset.h"
|
||||
|
||||
class BLOB_CHOICE_IT;
|
||||
class WERD_RES;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
// Class to iterate over tesseract results, providing access to all levels
|
||||
// of the page hierarchy, without including any tesseract headers or having
|
||||
// to handle any tesseract structures.
|
||||
// WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
// therefore can only be used while the TessBaseAPI class still exists and
|
||||
// has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
// DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
// See apitypes.h for the definition of PageIteratorLevel.
|
||||
// See also base class PageIterator, which contains the bulk of the interface.
|
||||
// LTRResultIterator adds text-specific methods for access to OCR output.
|
||||
|
||||
class TESS_API LTRResultIterator : public PageIterator {
|
||||
friend class ChoiceIterator;
|
||||
public:
|
||||
// page_res and tesseract come directly from the BaseAPI.
|
||||
// The rectangle parameters are copied indirectly from the Thresholder,
|
||||
// via the BaseAPI. They represent the coordinates of some rectangle in an
|
||||
// original image (in top-left-origin coordinates) and therefore the top-left
|
||||
// needs to be added to any output boxes in order to specify coordinates
|
||||
// in the original image. See TessBaseAPI::SetRectangle.
|
||||
// The scale and scaled_yres are in case the Thresholder scaled the image
|
||||
// rectangle prior to thresholding. Any coordinates in tesseract's image
|
||||
// must be divided by scale before adding (rect_left, rect_top).
|
||||
// The scaled_yres indicates the effective resolution of the binary image
|
||||
// that tesseract has been given by the Thresholder.
|
||||
// After the constructor, Begin has already been called.
|
||||
LTRResultIterator(PAGE_RES* page_res, Tesseract* tesseract,
|
||||
int scale, int scaled_yres,
|
||||
int rect_left, int rect_top,
|
||||
int rect_width, int rect_height);
|
||||
virtual ~LTRResultIterator();
|
||||
|
||||
// LTRResultIterators may be copied! This makes it possible to iterate over
|
||||
// all the objects at a lower level, while maintaining an iterator to
|
||||
// objects at a higher level. These constructors DO NOT CALL Begin, so
|
||||
// iterations will continue from the location of src.
|
||||
// TODO: For now the copy constructor and operator= only need the base class
|
||||
// versions, but if new data members are added, don't forget to add them!
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
|
||||
// See PageIterator.
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
|
||||
// Returns the null terminated UTF-8 encoded text string for the current
|
||||
// object at the given level. Use delete [] to free after use.
|
||||
char* GetUTF8Text(PageIteratorLevel level) const;
|
||||
|
||||
// Set the string inserted at the end of each text line. "\n" by default.
|
||||
void SetLineSeparator(const char *new_line);
|
||||
|
||||
// Set the string inserted at the end of each paragraph. "\n" by default.
|
||||
void SetParagraphSeparator(const char *new_para);
|
||||
|
||||
// Returns the mean confidence of the current object at the given level.
|
||||
// The number should be interpreted as a percent probability. (0.0f-100.0f)
|
||||
float Confidence(PageIteratorLevel level) const;
|
||||
|
||||
// ============= Functions that refer to words only ============.
|
||||
|
||||
// Returns the font attributes of the current word. If iterating at a higher
|
||||
// level object than words, eg textlines, then this will return the
|
||||
// attributes of the first word in that textline.
|
||||
// The actual return value is a string representing a font name. It points
|
||||
// to an internal table and SHOULD NOT BE DELETED. Lifespan is the same as
|
||||
// the iterator itself, ie rendered invalid by various members of
|
||||
// TessBaseAPI, including Init, SetImage, End or deleting the TessBaseAPI.
|
||||
// Pointsize is returned in printers points (1/72 inch.)
|
||||
const char* WordFontAttributes(bool* is_bold,
|
||||
bool* is_italic,
|
||||
bool* is_underlined,
|
||||
bool* is_monospace,
|
||||
bool* is_serif,
|
||||
bool* is_smallcaps,
|
||||
int* pointsize,
|
||||
int* font_id) const;
|
||||
|
||||
// Return the name of the language used to recognize this word.
|
||||
// On error, NULL. Do not delete this pointer.
|
||||
const char* WordRecognitionLanguage() const;
|
||||
|
||||
// Return the overall directionality of this word.
|
||||
StrongScriptDirection WordDirection() const;
|
||||
|
||||
// Returns true if the current word was found in a dictionary.
|
||||
bool WordIsFromDictionary() const;
|
||||
|
||||
// Returns true if the current word is numeric.
|
||||
bool WordIsNumeric() const;
|
||||
|
||||
// Returns true if the word contains blamer information.
|
||||
bool HasBlamerInfo() const;
|
||||
|
||||
// Returns the pointer to ParamsTrainingBundle stored in the BlamerBundle
|
||||
// of the current word.
|
||||
void *GetParamsTrainingBundle() const;
|
||||
|
||||
// Returns a pointer to the string with blamer information for this word.
|
||||
// Assumes that the word's blamer_bundle is not NULL.
|
||||
const char *GetBlamerDebug() const;
|
||||
|
||||
// Returns a pointer to the string with misadaption information for this word.
|
||||
// Assumes that the word's blamer_bundle is not NULL.
|
||||
const char *GetBlamerMisadaptionDebug() const;
|
||||
|
||||
// Returns a null terminated UTF-8 encoded truth string for the current word.
|
||||
// Use delete [] to free after use.
|
||||
char* WordTruthUTF8Text() const;
|
||||
|
||||
// Returns a pointer to serialized choice lattice.
|
||||
// Fills lattice_size with the number of bytes in lattice data.
|
||||
const char *WordLattice(int *lattice_size) const;
|
||||
|
||||
// ============= Functions that refer to symbols only ============.
|
||||
|
||||
// Returns true if the current symbol is a superscript.
|
||||
// If iterating at a higher level object than symbols, eg words, then
|
||||
// this will return the attributes of the first symbol in that word.
|
||||
bool SymbolIsSuperscript() const;
|
||||
// Returns true if the current symbol is a subscript.
|
||||
// If iterating at a higher level object than symbols, eg words, then
|
||||
// this will return the attributes of the first symbol in that word.
|
||||
bool SymbolIsSubscript() const;
|
||||
// Returns true if the current symbol is a dropcap.
|
||||
// If iterating at a higher level object than symbols, eg words, then
|
||||
// this will return the attributes of the first symbol in that word.
|
||||
bool SymbolIsDropcap() const;
|
||||
|
||||
protected:
|
||||
const char *line_separator_;
|
||||
const char *paragraph_separator_;
|
||||
};
|
||||
|
||||
// Class to iterate over the classifier choices for a single RIL_SYMBOL.
|
||||
class ChoiceIterator {
|
||||
public:
|
||||
// Construction is from a LTRResultIterator that points to the symbol of
|
||||
// interest. The ChoiceIterator allows a one-shot iteration over the
|
||||
// choices for this symbol and after that is is useless.
|
||||
explicit ChoiceIterator(const LTRResultIterator& result_it);
|
||||
~ChoiceIterator();
|
||||
|
||||
// Moves to the next choice for the symbol and returns false if there
|
||||
// are none left.
|
||||
bool Next();
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
|
||||
// Returns the null terminated UTF-8 encoded text string for the current
|
||||
// choice.
|
||||
// NOTE: Unlike LTRResultIterator::GetUTF8Text, the return points to an
|
||||
// internal structure and should NOT be delete[]ed to free after use.
|
||||
const char* GetUTF8Text() const;
|
||||
|
||||
// Returns the confidence of the current choice.
|
||||
// The number should be interpreted as a percent probability. (0.0f-100.0f)
|
||||
float Confidence() const;
|
||||
|
||||
private:
|
||||
// Pointer to the WERD_RES object owned by the API.
|
||||
WERD_RES* word_res_;
|
||||
// Iterator over the blob choices.
|
||||
BLOB_CHOICE_IT* choice_it_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H__
|
||||
@@ -1,43 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: memry.h (Formerly memory.h)
|
||||
* Description: Header file for basic memory allocation/deallocation.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue May 8 16:03:48 BST 1990
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef MEMRY_H
|
||||
#define MEMRY_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "host.h"
|
||||
|
||||
// allocate string
|
||||
extern char *alloc_string(inT32 count);
|
||||
// free a string.
|
||||
extern void free_string(char *string);
|
||||
// allocate memory
|
||||
extern void *alloc_struct(inT32 count, const char *name = NULL);
|
||||
// free a structure.
|
||||
extern void free_struct(void *deadstruct, inT32, const char *name = NULL);
|
||||
// get some memory
|
||||
extern void *alloc_mem(inT32 count);
|
||||
// get some memory initialized to 0.
|
||||
extern void *alloc_big_zeros(inT32 count);
|
||||
// free mem from alloc_mem
|
||||
extern void free_mem(void *oldchunk);
|
||||
// free mem from alloc_big_zeros
|
||||
extern void free_big_mem(void *oldchunk);
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: ndminx.h (Formerly ndminmax.h)
|
||||
* Description: Extended ascii chars
|
||||
* Author: Phil Cheatle
|
||||
* Created: Mon Mar 29 14:46:01 BST 1993
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef NDMINX_H
|
||||
#define NDMINX_H
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) (((x) >= (y))?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) (((x) <= (y))?(x):(y))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,327 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: pageiterator.h
|
||||
// Description: Iterator for tesseract page structure that avoids using
|
||||
// tesseract internal data structures.
|
||||
// Author: Ray Smith
|
||||
// Created: Fri Feb 26 11:01:06 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_PAGEITERATOR_H__
|
||||
#define TESSERACT_CCMAIN_PAGEITERATOR_H__
|
||||
|
||||
#include "publictypes.h"
|
||||
#include "platform.h"
|
||||
|
||||
class C_BLOB_IT;
|
||||
class PBLOB_IT;
|
||||
class PAGE_RES;
|
||||
class PAGE_RES_IT;
|
||||
class WERD;
|
||||
struct Pix;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
/**
|
||||
* Class to iterate over tesseract page structure, providing access to all
|
||||
* levels of the page hierarchy, without including any tesseract headers or
|
||||
* having to handle any tesseract structures.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
* See apitypes.h for the definition of PageIteratorLevel.
|
||||
* See also ResultIterator, derived from PageIterator, which adds in the
|
||||
* ability to access OCR output with text-specific methods.
|
||||
*/
|
||||
|
||||
class TESS_API PageIterator {
|
||||
public:
|
||||
/**
|
||||
* page_res and tesseract come directly from the BaseAPI.
|
||||
* The rectangle parameters are copied indirectly from the Thresholder,
|
||||
* via the BaseAPI. They represent the coordinates of some rectangle in an
|
||||
* original image (in top-left-origin coordinates) and therefore the top-left
|
||||
* needs to be added to any output boxes in order to specify coordinates
|
||||
* in the original image. See TessBaseAPI::SetRectangle.
|
||||
* The scale and scaled_yres are in case the Thresholder scaled the image
|
||||
* rectangle prior to thresholding. Any coordinates in tesseract's image
|
||||
* must be divided by scale before adding (rect_left, rect_top).
|
||||
* The scaled_yres indicates the effective resolution of the binary image
|
||||
* that tesseract has been given by the Thresholder.
|
||||
* After the constructor, Begin has already been called.
|
||||
*/
|
||||
PageIterator(PAGE_RES* page_res, Tesseract* tesseract,
|
||||
int scale, int scaled_yres,
|
||||
int rect_left, int rect_top,
|
||||
int rect_width, int rect_height);
|
||||
virtual ~PageIterator();
|
||||
|
||||
/**
|
||||
* Page/ResultIterators may be copied! This makes it possible to iterate over
|
||||
* all the objects at a lower level, while maintaining an iterator to
|
||||
* objects at a higher level. These constructors DO NOT CALL Begin, so
|
||||
* iterations will continue from the location of src.
|
||||
*/
|
||||
PageIterator(const PageIterator& src);
|
||||
const PageIterator& operator=(const PageIterator& src);
|
||||
|
||||
/** Are we positioned at the same location as other? */
|
||||
bool PositionedAtSameWord(const PAGE_RES_IT* other) const;
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
|
||||
/**
|
||||
* Moves the iterator to point to the start of the page to begin an
|
||||
* iteration.
|
||||
*/
|
||||
virtual void Begin();
|
||||
|
||||
/**
|
||||
* Moves the iterator to the beginning of the paragraph.
|
||||
* This class implements this functionality by moving it to the zero indexed
|
||||
* blob of the first (leftmost) word on the first row of the paragraph.
|
||||
*/
|
||||
virtual void RestartParagraph();
|
||||
|
||||
/**
|
||||
* Return whether this iterator points anywhere in the first textline of a
|
||||
* paragraph.
|
||||
*/
|
||||
bool IsWithinFirstTextlineOfParagraph() const;
|
||||
|
||||
/**
|
||||
* Moves the iterator to the beginning of the text line.
|
||||
* This class implements this functionality by moving it to the zero indexed
|
||||
* blob of the first (leftmost) word of the row.
|
||||
*/
|
||||
virtual void RestartRow();
|
||||
|
||||
/**
|
||||
* Moves to the start of the next object at the given level in the
|
||||
* page hierarchy, and returns false if the end of the page was reached.
|
||||
* NOTE that RIL_SYMBOL will skip non-text blocks, but all other
|
||||
* PageIteratorLevel level values will visit each non-text block once.
|
||||
* Think of non text blocks as containing a single para, with a single line,
|
||||
* with a single imaginary word.
|
||||
* Calls to Next with different levels may be freely intermixed.
|
||||
* This function iterates words in right-to-left scripts correctly, if
|
||||
* the appropriate language has been loaded into Tesseract.
|
||||
*/
|
||||
virtual bool Next(PageIteratorLevel level);
|
||||
|
||||
/**
|
||||
* Returns true if the iterator is at the start of an object at the given
|
||||
* level.
|
||||
*
|
||||
* For instance, suppose an iterator it is pointed to the first symbol of the
|
||||
* first word of the third line of the second paragraph of the first block in
|
||||
* a page, then:
|
||||
* it.IsAtBeginningOf(RIL_BLOCK) = false
|
||||
* it.IsAtBeginningOf(RIL_PARA) = false
|
||||
* it.IsAtBeginningOf(RIL_TEXTLINE) = true
|
||||
* it.IsAtBeginningOf(RIL_WORD) = true
|
||||
* it.IsAtBeginningOf(RIL_SYMBOL) = true
|
||||
*/
|
||||
virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns whether the iterator is positioned at the last element in a
|
||||
* given level. (e.g. the last word in a line, the last line in a block)
|
||||
*
|
||||
* Here's some two-paragraph example
|
||||
* text. It starts off innocuously
|
||||
* enough but quickly turns bizarre.
|
||||
* The author inserts a cornucopia
|
||||
* of words to guard against confused
|
||||
* references.
|
||||
*
|
||||
* Now take an iterator it pointed to the start of "bizarre."
|
||||
* it.IsAtFinalElement(RIL_PARA, RIL_SYMBOL) = false
|
||||
* it.IsAtFinalElement(RIL_PARA, RIL_WORD) = true
|
||||
* it.IsAtFinalElement(RIL_BLOCK, RIL_WORD) = false
|
||||
*/
|
||||
virtual bool IsAtFinalElement(PageIteratorLevel level,
|
||||
PageIteratorLevel element) const;
|
||||
|
||||
/**
|
||||
* Returns whether this iterator is positioned
|
||||
* before other: -1
|
||||
* equal to other: 0
|
||||
* after other: 1
|
||||
*/
|
||||
int Cmp(const PageIterator &other) const;
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
// Coordinate system:
|
||||
// Integer coordinates are at the cracks between the pixels.
|
||||
// The top-left corner of the top-left pixel in the image is at (0,0).
|
||||
// The bottom-right corner of the bottom-right pixel in the image is at
|
||||
// (width, height).
|
||||
// Every bounding box goes from the top-left of the top-left contained
|
||||
// pixel to the bottom-right of the bottom-right contained pixel, so
|
||||
// the bounding box of the single top-left pixel in the image is:
|
||||
// (0,0)->(1,1).
|
||||
// If an image rectangle has been set in the API, then returned coordinates
|
||||
// relate to the original (full) image, rather than the rectangle.
|
||||
|
||||
/**
|
||||
* Returns the bounding rectangle of the current object at the given level.
|
||||
* See comment on coordinate system above.
|
||||
* Returns false if there is no such object at the current position.
|
||||
* The returned bounding box is guaranteed to match the size and position
|
||||
* of the image returned by GetBinaryImage, but may clip foreground pixels
|
||||
* from a grey image. The padding argument to GetImage can be used to expand
|
||||
* the image to include more foreground pixels. See GetImage below.
|
||||
*/
|
||||
bool BoundingBox(PageIteratorLevel level,
|
||||
int* left, int* top, int* right, int* bottom) const;
|
||||
/**
|
||||
* Returns the bounding rectangle of the object in a coordinate system of the
|
||||
* working image rectangle having its origin at (rect_left_, rect_top_) with
|
||||
* respect to the original image and is scaled by a factor scale_.
|
||||
*/
|
||||
bool BoundingBoxInternal(PageIteratorLevel level,
|
||||
int* left, int* top, int* right, int* bottom) const;
|
||||
|
||||
/** Returns whether there is no object of a given level. */
|
||||
bool Empty(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns the type of the current block. See apitypes.h for
|
||||
* PolyBlockType.
|
||||
*/
|
||||
PolyBlockType BlockType() const;
|
||||
|
||||
/**
|
||||
* Returns a binary image of the current object at the given level.
|
||||
* The position and size match the return from BoundingBoxInternal, and so
|
||||
* this could be upscaled with respect to the original input image.
|
||||
* Use pixDestroy to delete the image after use.
|
||||
*/
|
||||
Pix* GetBinaryImage(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns an image of the current object at the given level in greyscale
|
||||
* if available in the input. To guarantee a binary image use BinaryImage.
|
||||
* NOTE that in order to give the best possible image, the bounds are
|
||||
* expanded slightly over the binary connected component, by the supplied
|
||||
* padding, so the top-left position of the returned image is returned
|
||||
* in (left,top). These will most likely not match the coordinates
|
||||
* returned by BoundingBox.
|
||||
* Use pixDestroy to delete the image after use.
|
||||
*/
|
||||
Pix* GetImage(PageIteratorLevel level, int padding,
|
||||
int* left, int* top) const;
|
||||
|
||||
/**
|
||||
* Returns the baseline of the current object at the given level.
|
||||
* The baseline is the line that passes through (x1, y1) and (x2, y2).
|
||||
* WARNING: with vertical text, baselines may be vertical!
|
||||
* Returns false if there is no baseline at the current position.
|
||||
*/
|
||||
bool Baseline(PageIteratorLevel level,
|
||||
int* x1, int* y1, int* x2, int* y2) const;
|
||||
|
||||
/**
|
||||
* Returns orientation for the block the iterator points to.
|
||||
* orientation, writing_direction, textline_order: see publictypes.h
|
||||
* deskew_angle: after rotating the block so the text orientation is
|
||||
* upright, how many radians does one have to rotate the
|
||||
* block anti-clockwise for it to be level?
|
||||
* -Pi/4 <= deskew_angle <= Pi/4
|
||||
*/
|
||||
void Orientation(tesseract::Orientation *orientation,
|
||||
tesseract::WritingDirection *writing_direction,
|
||||
tesseract::TextlineOrder *textline_order,
|
||||
float *deskew_angle) const;
|
||||
|
||||
/**
|
||||
* Returns information about the current paragraph, if available.
|
||||
*
|
||||
* justification -
|
||||
* LEFT if ragged right, or fully justified and script is left-to-right.
|
||||
* RIGHT if ragged left, or fully justified and script is right-to-left.
|
||||
* unknown if it looks like source code or we have very few lines.
|
||||
* is_list_item -
|
||||
* true if we believe this is a member of an ordered or unordered list.
|
||||
* is_crown -
|
||||
* true if the first line of the paragraph is aligned with the other
|
||||
* lines of the paragraph even though subsequent paragraphs have first
|
||||
* line indents. This typically indicates that this is the continuation
|
||||
* of a previous paragraph or that it is the very first paragraph in
|
||||
* the chapter.
|
||||
* first_line_indent -
|
||||
* For LEFT aligned paragraphs, the first text line of paragraphs of
|
||||
* this kind are indented this many pixels from the left edge of the
|
||||
* rest of the paragraph.
|
||||
* for RIGHT aligned paragraphs, the first text line of paragraphs of
|
||||
* this kind are indented this many pixels from the right edge of the
|
||||
* rest of the paragraph.
|
||||
* NOTE 1: This value may be negative.
|
||||
* NOTE 2: if *is_crown == true, the first line of this paragraph is
|
||||
* actually flush, and first_line_indent is set to the "common"
|
||||
* first_line_indent for subsequent paragraphs in this block
|
||||
* of text.
|
||||
*/
|
||||
void ParagraphInfo(tesseract::ParagraphJustification *justification,
|
||||
bool *is_list_item,
|
||||
bool *is_crown,
|
||||
int *first_line_indent) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Sets up the internal data for iterating the blobs of a new word, then
|
||||
* moves the iterator to the given offset.
|
||||
*/
|
||||
TESS_LOCAL void BeginWord(int offset);
|
||||
|
||||
/** Pointer to the page_res owned by the API. */
|
||||
PAGE_RES* page_res_;
|
||||
/** Pointer to the Tesseract object owned by the API. */
|
||||
Tesseract* tesseract_;
|
||||
/**
|
||||
* The iterator to the page_res_. Owned by this ResultIterator.
|
||||
* A pointer just to avoid dragging in Tesseract includes.
|
||||
*/
|
||||
PAGE_RES_IT* it_;
|
||||
/**
|
||||
* The current input WERD being iterated. If there is an output from OCR,
|
||||
* then word_ is NULL. Owned by the API
|
||||
*/
|
||||
WERD* word_;
|
||||
/** The length of the current word_. */
|
||||
int word_length_;
|
||||
/** The current blob index within the word. */
|
||||
int blob_index_;
|
||||
/**
|
||||
* Iterator to the blobs within the word. If NULL, then we are iterating
|
||||
* OCR results in the box_word.
|
||||
* Owned by this ResultIterator.
|
||||
*/
|
||||
C_BLOB_IT* cblob_it_;
|
||||
/** Parameters saved from the Thresholder. Needed to rebuild coordinates.*/
|
||||
int scale_;
|
||||
int scaled_yres_;
|
||||
int rect_left_;
|
||||
int rect_top_;
|
||||
int rect_width_;
|
||||
int rect_height_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_PAGEITERATOR_H__
|
||||
@@ -1,296 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: params.h
|
||||
* Description: Class definitions of the *_VAR classes for tunable constants.
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Feb 22 11:26:25 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef PARAMS_H
|
||||
#define PARAMS_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "genericvector.h"
|
||||
#include "strngs.h"
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class IntParam;
|
||||
class BoolParam;
|
||||
class StringParam;
|
||||
class DoubleParam;
|
||||
|
||||
// Enum for constraints on what kind of params should be set by SetParam().
|
||||
enum SetParamConstraint {
|
||||
SET_PARAM_CONSTRAINT_NONE,
|
||||
SET_PARAM_CONSTRAINT_DEBUG_ONLY,
|
||||
SET_PARAM_CONSTRAINT_NON_DEBUG_ONLY,
|
||||
SET_PARAM_CONSTRAINT_NON_INIT_ONLY,
|
||||
};
|
||||
|
||||
struct ParamsVectors {
|
||||
GenericVector<IntParam *> int_params;
|
||||
GenericVector<BoolParam *> bool_params;
|
||||
GenericVector<StringParam *> string_params;
|
||||
GenericVector<DoubleParam *> double_params;
|
||||
};
|
||||
|
||||
// Utility functions for working with Tesseract parameters.
|
||||
class ParamUtils {
|
||||
public:
|
||||
// Reads a file of parameter definitions and set/modify the values therein.
|
||||
// If the filename begins with a + or -, the BoolVariables will be
|
||||
// ORed or ANDed with any current values.
|
||||
// Blank lines and lines beginning # are ignored.
|
||||
// Values may have any whitespace after the name and are the rest of line.
|
||||
static bool ReadParamsFile(
|
||||
const char *file, // filename to read
|
||||
SetParamConstraint constraint,
|
||||
ParamsVectors *member_params);
|
||||
|
||||
// Read parameters from the given file pointer (stop at end_offset).
|
||||
static bool ReadParamsFromFp(FILE *fp, inT64 end_offset,
|
||||
SetParamConstraint constraint,
|
||||
ParamsVectors *member_params);
|
||||
|
||||
// Set a parameters to have the given value.
|
||||
static bool SetParam(const char *name, const char* value,
|
||||
SetParamConstraint constraint,
|
||||
ParamsVectors *member_params);
|
||||
|
||||
// Returns the pointer to the parameter with the given name (of the
|
||||
// appropriate type) if it was found in the vector obtained from
|
||||
// GlobalParams() or in the given member_params.
|
||||
template<class T>
|
||||
static T *FindParam(const char *name,
|
||||
const GenericVector<T *> &global_vec,
|
||||
const GenericVector<T *> &member_vec) {
|
||||
int i;
|
||||
for (i = 0; i < global_vec.size(); ++i) {
|
||||
if (strcmp(global_vec[i]->name_str(), name) == 0) return global_vec[i];
|
||||
}
|
||||
for (i = 0; i < member_vec.size(); ++i) {
|
||||
if (strcmp(member_vec[i]->name_str(), name) == 0) return member_vec[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
// Removes the given pointer to the param from the given vector.
|
||||
template<class T>
|
||||
static void RemoveParam(T *param_ptr, GenericVector<T *> *vec) {
|
||||
for (int i = 0; i < vec->size(); ++i) {
|
||||
if ((*vec)[i] == param_ptr) {
|
||||
vec->remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fetches the value of the named param as a STRING. Returns false if not
|
||||
// found.
|
||||
static bool GetParamAsString(const char *name,
|
||||
const ParamsVectors* member_params,
|
||||
STRING *value);
|
||||
|
||||
// Print parameters to the given file.
|
||||
static void PrintParams(FILE *fp, const ParamsVectors *member_params);
|
||||
};
|
||||
|
||||
// Definition of various parameter types.
|
||||
class Param {
|
||||
public:
|
||||
~Param() {}
|
||||
|
||||
const char *name_str() const { return name_; }
|
||||
const char *info_str() const { return info_; }
|
||||
bool is_init() const { return init_; }
|
||||
bool is_debug() const { return debug_; }
|
||||
bool constraint_ok(SetParamConstraint constraint) const {
|
||||
return (constraint == SET_PARAM_CONSTRAINT_NONE ||
|
||||
(constraint == SET_PARAM_CONSTRAINT_DEBUG_ONLY &&
|
||||
this->is_debug()) ||
|
||||
(constraint == SET_PARAM_CONSTRAINT_NON_DEBUG_ONLY &&
|
||||
!this->is_debug()) ||
|
||||
(constraint == SET_PARAM_CONSTRAINT_NON_INIT_ONLY &&
|
||||
!this->is_init()));
|
||||
}
|
||||
|
||||
protected:
|
||||
Param(const char *name, const char *comment, bool init) :
|
||||
name_(name), info_(comment), init_(init) {
|
||||
debug_ = (strstr(name, "debug") != NULL) || (strstr(name, "display"));
|
||||
}
|
||||
|
||||
const char *name_; // name of this parameter
|
||||
const char *info_; // for menus
|
||||
bool init_; // needs to be set before init
|
||||
bool debug_;
|
||||
};
|
||||
|
||||
class IntParam : public Param {
|
||||
public:
|
||||
IntParam(inT32 value, const char *name, const char *comment, bool init,
|
||||
ParamsVectors *vec) : Param(name, comment, init) {
|
||||
value_ = value;
|
||||
params_vec_ = &(vec->int_params);
|
||||
vec->int_params.push_back(this);
|
||||
}
|
||||
~IntParam() { ParamUtils::RemoveParam<IntParam>(this, params_vec_); }
|
||||
operator inT32() const { return value_; }
|
||||
void set_value(inT32 value) { value_ = value; }
|
||||
|
||||
private:
|
||||
inT32 value_;
|
||||
// Pointer to the vector that contains this param (not owened by this class).
|
||||
GenericVector<IntParam *> *params_vec_;
|
||||
};
|
||||
|
||||
class BoolParam : public Param {
|
||||
public:
|
||||
BoolParam(bool value, const char *name, const char *comment, bool init,
|
||||
ParamsVectors *vec) : Param(name, comment, init) {
|
||||
value_ = value;
|
||||
params_vec_ = &(vec->bool_params);
|
||||
vec->bool_params.push_back(this);
|
||||
}
|
||||
~BoolParam() { ParamUtils::RemoveParam<BoolParam>(this, params_vec_); }
|
||||
operator BOOL8() const { return value_; }
|
||||
void set_value(BOOL8 value) { value_ = value; }
|
||||
|
||||
private:
|
||||
BOOL8 value_;
|
||||
// Pointer to the vector that contains this param (not owned by this class).
|
||||
GenericVector<BoolParam *> *params_vec_;
|
||||
};
|
||||
|
||||
class StringParam : public Param {
|
||||
public:
|
||||
StringParam(const char *value, const char *name,
|
||||
const char *comment, bool init,
|
||||
ParamsVectors *vec) : Param(name, comment, init) {
|
||||
value_ = value;
|
||||
params_vec_ = &(vec->string_params);
|
||||
vec->string_params.push_back(this);
|
||||
}
|
||||
~StringParam() { ParamUtils::RemoveParam<StringParam>(this, params_vec_); }
|
||||
operator STRING &() { return value_; }
|
||||
const char *string() const { return value_.string(); }
|
||||
bool empty() { return value_.length() <= 0; }
|
||||
void set_value(const STRING &value) { value_ = value; }
|
||||
|
||||
private:
|
||||
STRING value_;
|
||||
// Pointer to the vector that contains this param (not owened by this class).
|
||||
GenericVector<StringParam *> *params_vec_;
|
||||
};
|
||||
|
||||
class DoubleParam : public Param {
|
||||
public:
|
||||
DoubleParam(double value, const char *name, const char *comment,
|
||||
bool init, ParamsVectors *vec) : Param(name, comment, init) {
|
||||
value_ = value;
|
||||
params_vec_ = &(vec->double_params);
|
||||
vec->double_params.push_back(this);
|
||||
}
|
||||
~DoubleParam() { ParamUtils::RemoveParam<DoubleParam>(this, params_vec_); }
|
||||
operator double() const { return value_; }
|
||||
void set_value(double value) { value_ = value; }
|
||||
|
||||
private:
|
||||
double value_;
|
||||
// Pointer to the vector that contains this param (not owned by this class).
|
||||
GenericVector<DoubleParam *> *params_vec_;
|
||||
};
|
||||
|
||||
} // namespace tesseract
|
||||
|
||||
// Global parameter lists.
|
||||
//
|
||||
// To avoid the problem of undetermined order of static initialization
|
||||
// global_params are accessed through the GlobalParams function that
|
||||
// initializes the static pointer to global_params only on the first
|
||||
// first time GlobalParams() is called.
|
||||
//
|
||||
// TODO(daria): remove GlobalParams() when all global Tesseract
|
||||
// parameters are converted to members.
|
||||
tesseract::ParamsVectors *GlobalParams();
|
||||
|
||||
/*************************************************************************
|
||||
* Note on defining parameters.
|
||||
*
|
||||
* The values of the parameters defined with *_INIT_* macros are guaranteed
|
||||
* to be loaded from config files before Tesseract initialization is done
|
||||
* (there is no such guarantee for parameters defined with the other macros).
|
||||
*************************************************************************/
|
||||
|
||||
#define INT_VAR_H(name,val,comment)\
|
||||
tesseract::IntParam name
|
||||
|
||||
#define BOOL_VAR_H(name,val,comment)\
|
||||
tesseract::BoolParam name
|
||||
|
||||
#define STRING_VAR_H(name,val,comment)\
|
||||
tesseract::StringParam name
|
||||
|
||||
#define double_VAR_H(name,val,comment)\
|
||||
tesseract::DoubleParam name
|
||||
|
||||
#define INT_VAR(name,val,comment)\
|
||||
tesseract::IntParam name(val,#name,comment,false,GlobalParams())
|
||||
|
||||
#define BOOL_VAR(name,val,comment)\
|
||||
tesseract::BoolParam name(val,#name,comment,false,GlobalParams())
|
||||
|
||||
#define STRING_VAR(name,val,comment)\
|
||||
tesseract::StringParam name(val,#name,comment,false,GlobalParams())
|
||||
|
||||
#define double_VAR(name,val,comment)\
|
||||
tesseract::DoubleParam name(val,#name,comment,false,GlobalParams())
|
||||
|
||||
#define INT_INIT_VAR(name,val,comment)\
|
||||
tesseract::IntParam name(val,#name,comment,true,GlobalParams())
|
||||
|
||||
#define BOOL_INIT_VAR(name,val,comment)\
|
||||
tesseract::BoolParam name(val,#name,comment,true,GlobalParams())
|
||||
|
||||
#define STRING_INIT_VAR(name,val,comment)\
|
||||
tesseract::StringParam name(val,#name,comment,true,GlobalParams())
|
||||
|
||||
#define double_INIT_VAR(name,val,comment)\
|
||||
tesseract::DoubleParam name(val,#name,comment,true,GlobalParams())
|
||||
|
||||
#define INT_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, false, vec)
|
||||
|
||||
#define BOOL_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, false, vec)
|
||||
|
||||
#define STRING_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, false, vec)
|
||||
|
||||
#define double_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, false, vec)
|
||||
|
||||
#define INT_INIT_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, true, vec)
|
||||
|
||||
#define BOOL_INIT_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, true, vec)
|
||||
|
||||
#define STRING_INIT_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, true, vec)
|
||||
|
||||
#define double_INIT_MEMBER(name, val, comment, vec)\
|
||||
name(val, #name, comment, true, vec)
|
||||
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: platform.h
|
||||
// Description: Place holder
|
||||
// Author:
|
||||
// Created:
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_PLATFORM_H__
|
||||
#define TESSERACT_CCUTIL_PLATFORM_H__
|
||||
|
||||
#define DLLSYM
|
||||
#ifdef _WIN32
|
||||
#ifdef __GNUC__
|
||||
#define ultoa _ultoa
|
||||
typedef struct _BLOB {
|
||||
unsigned int cbSize;
|
||||
char *pBlobData;
|
||||
} BLOB, *LPBLOB;
|
||||
#endif /* __GNUC__ */
|
||||
#define SIGNED
|
||||
#define snprintf _snprintf
|
||||
#if (_MSC_VER <= 1400)
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif /* _WIN32 */
|
||||
#else
|
||||
#define __UNIX__
|
||||
#include <limits.h>
|
||||
#ifndef PATH_MAX
|
||||
#define MAX_PATH 4096
|
||||
#else
|
||||
#define MAX_PATH PATH_MAX
|
||||
#endif
|
||||
#define SIGNED signed
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#if defined(TESS_EXPORTS)
|
||||
#define TESS_API __declspec(dllexport)
|
||||
#elif defined(TESS_IMPORTS)
|
||||
#define TESS_API __declspec(dllimport)
|
||||
#else
|
||||
#define TESS_API
|
||||
#endif
|
||||
#define TESS_LOCAL
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#if defined(TESS_EXPORTS) || defined(TESS_IMPORTS)
|
||||
#define TESS_API __attribute__ ((visibility ("default")))
|
||||
#define TESS_LOCAL __attribute__ ((visibility ("hidden")))
|
||||
#else
|
||||
#define TESS_API
|
||||
#define TESS_LOCAL
|
||||
#endif
|
||||
#else
|
||||
#define TESS_API
|
||||
#define TESS_LOCAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // TESSERACT_CCUTIL_PLATFORM_H__
|
||||
@@ -1,249 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: publictypes.h
|
||||
// Description: Types used in both the API and internally
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Mar 03 09:22:53 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCSTRUCT_PUBLICTYPES_H__
|
||||
#define TESSERACT_CCSTRUCT_PUBLICTYPES_H__
|
||||
|
||||
// This file contains types that are used both by the API and internally
|
||||
// to Tesseract. In order to decouple the API from Tesseract and prevent cyclic
|
||||
// dependencies, THIS FILE SHOULD NOT DEPEND ON ANY OTHER PART OF TESSERACT.
|
||||
// Restated: It is OK for low-level Tesseract files to include publictypes.h,
|
||||
// but not for the low-level tesseract code to include top-level API code.
|
||||
// This file should not use other Tesseract types, as that would drag
|
||||
// their includes into the API-level.
|
||||
// API-level code should include apitypes.h in preference to this file.
|
||||
|
||||
/** Number of printers' points in an inch. The unit of the pointsize return. */
|
||||
const int kPointsPerInch = 72;
|
||||
|
||||
/**
|
||||
* Possible types for a POLY_BLOCK or ColPartition.
|
||||
* Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
|
||||
* below, as well as kPolyBlockNames in publictypes.cpp.
|
||||
* Used extensively by ColPartition, and POLY_BLOCK.
|
||||
*/
|
||||
enum PolyBlockType {
|
||||
PT_UNKNOWN, // Type is not yet known. Keep as the first element.
|
||||
PT_FLOWING_TEXT, // Text that lives inside a column.
|
||||
PT_HEADING_TEXT, // Text that spans more than one column.
|
||||
PT_PULLOUT_TEXT, // Text that is in a cross-column pull-out region.
|
||||
PT_EQUATION, // Partition belonging to an equation region.
|
||||
PT_INLINE_EQUATION, // Partition has inline equation.
|
||||
PT_TABLE, // Partition belonging to a table region.
|
||||
PT_VERTICAL_TEXT, // Text-line runs vertically.
|
||||
PT_CAPTION_TEXT, // Text that belongs to an image.
|
||||
PT_FLOWING_IMAGE, // Image that lives inside a column.
|
||||
PT_HEADING_IMAGE, // Image that spans more than one column.
|
||||
PT_PULLOUT_IMAGE, // Image that is in a cross-column pull-out region.
|
||||
PT_HORZ_LINE, // Horizontal Line.
|
||||
PT_VERT_LINE, // Vertical Line.
|
||||
PT_NOISE, // Lies outside of any column.
|
||||
PT_COUNT
|
||||
};
|
||||
|
||||
/** Returns true if PolyBlockType is of horizontal line type */
|
||||
inline bool PTIsLineType(PolyBlockType type) {
|
||||
return type == PT_HORZ_LINE || type == PT_VERT_LINE;
|
||||
}
|
||||
/** Returns true if PolyBlockType is of image type */
|
||||
inline bool PTIsImageType(PolyBlockType type) {
|
||||
return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
|
||||
type == PT_PULLOUT_IMAGE;
|
||||
}
|
||||
/** Returns true if PolyBlockType is of text type */
|
||||
inline bool PTIsTextType(PolyBlockType type) {
|
||||
return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
|
||||
type == PT_PULLOUT_TEXT || type == PT_TABLE ||
|
||||
type == PT_VERTICAL_TEXT || type == PT_CAPTION_TEXT ||
|
||||
type == PT_INLINE_EQUATION;
|
||||
}
|
||||
|
||||
/** String name for each block type. Keep in sync with PolyBlockType. */
|
||||
extern const char* kPolyBlockNames[];
|
||||
|
||||
namespace tesseract {
|
||||
/**
|
||||
* +------------------+ Orientation Example:
|
||||
* | 1 Aaaa Aaaa Aaaa | ====================
|
||||
* | Aaa aa aaa aa | To left is a diagram of some (1) English and
|
||||
* | aaaaaa A aa aaa. | (2) Chinese text and a (3) photo credit.
|
||||
* | 2 |
|
||||
* | ####### c c C | Upright Latin characters are represented as A and a.
|
||||
* | ####### c c c | '<' represents a latin character rotated
|
||||
* | < ####### c c c | anti-clockwise 90 degrees.
|
||||
* | < ####### c c |
|
||||
* | < ####### . c | Upright Chinese characters are represented C and c.
|
||||
* | 3 ####### c |
|
||||
* +------------------+ NOTA BENE: enum values here should match goodoc.proto
|
||||
|
||||
* If you orient your head so that "up" aligns with Orientation,
|
||||
* then the characters will appear "right side up" and readable.
|
||||
*
|
||||
* In the example above, both the English and Chinese paragraphs are oriented
|
||||
* so their "up" is the top of the page (page up). The photo credit is read
|
||||
* with one's head turned leftward ("up" is to page left).
|
||||
*
|
||||
* The values of this enum match the convention of Tesseract's osdetect.h
|
||||
*/
|
||||
enum Orientation {
|
||||
ORIENTATION_PAGE_UP = 0,
|
||||
ORIENTATION_PAGE_RIGHT = 1,
|
||||
ORIENTATION_PAGE_DOWN = 2,
|
||||
ORIENTATION_PAGE_LEFT = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* The grapheme clusters within a line of text are laid out logically
|
||||
* in this direction, judged when looking at the text line rotated so that
|
||||
* its Orientation is "page up".
|
||||
*
|
||||
* For English text, the writing direction is left-to-right. For the
|
||||
* Chinese text in the above example, the writing direction is top-to-bottom.
|
||||
*/
|
||||
enum WritingDirection {
|
||||
WRITING_DIRECTION_LEFT_TO_RIGHT = 0,
|
||||
WRITING_DIRECTION_RIGHT_TO_LEFT = 1,
|
||||
WRITING_DIRECTION_TOP_TO_BOTTOM = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* The text lines are read in the given sequence.
|
||||
*
|
||||
* In English, the order is top-to-bottom.
|
||||
* In Chinese, vertical text lines are read right-to-left. Mongolian is
|
||||
* written in vertical columns top to bottom like Chinese, but the lines
|
||||
* order left-to right.
|
||||
*
|
||||
* Note that only some combinations make sense. For example,
|
||||
* WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
|
||||
*/
|
||||
enum TextlineOrder {
|
||||
TEXTLINE_ORDER_LEFT_TO_RIGHT = 0,
|
||||
TEXTLINE_ORDER_RIGHT_TO_LEFT = 1,
|
||||
TEXTLINE_ORDER_TOP_TO_BOTTOM = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Possible modes for page layout analysis. These *must* be kept in order
|
||||
* of decreasing amount of layout analysis to be done, except for OSD_ONLY,
|
||||
* so that the inequality test macros below work.
|
||||
*/
|
||||
enum PageSegMode {
|
||||
PSM_OSD_ONLY, ///< Orientation and script detection only.
|
||||
PSM_AUTO_OSD, ///< Automatic page segmentation with orientation and
|
||||
///< script detection. (OSD)
|
||||
PSM_AUTO_ONLY, ///< Automatic page segmentation, but no OSD, or OCR.
|
||||
PSM_AUTO, ///< Fully automatic page segmentation, but no OSD.
|
||||
PSM_SINGLE_COLUMN, ///< Assume a single column of text of variable sizes.
|
||||
PSM_SINGLE_BLOCK_VERT_TEXT, ///< Assume a single uniform block of vertically
|
||||
///< aligned text.
|
||||
PSM_SINGLE_BLOCK, ///< Assume a single uniform block of text. (Default.)
|
||||
PSM_SINGLE_LINE, ///< Treat the image as a single text line.
|
||||
PSM_SINGLE_WORD, ///< Treat the image as a single word.
|
||||
PSM_CIRCLE_WORD, ///< Treat the image as a single word in a circle.
|
||||
PSM_SINGLE_CHAR, ///< Treat the image as a single character.
|
||||
|
||||
PSM_COUNT ///< Number of enum entries.
|
||||
};
|
||||
|
||||
/**
|
||||
* Macros that act on a PageSegMode to determine whether components of
|
||||
* layout analysis are enabled.
|
||||
* *Depend critically on the order of elements of PageSegMode.*
|
||||
*/
|
||||
#define PSM_OSD_ENABLED(pageseg_mode) ((pageseg_mode) <= PSM_AUTO_OSD)
|
||||
#define PSM_COL_FIND_ENABLED(pageseg_mode) \
|
||||
((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_AUTO)
|
||||
#define PSM_BLOCK_FIND_ENABLED(pageseg_mode) \
|
||||
((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_COLUMN)
|
||||
#define PSM_LINE_FIND_ENABLED(pageseg_mode) \
|
||||
((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_BLOCK)
|
||||
#define PSM_WORD_FIND_ENABLED(pageseg_mode) \
|
||||
((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_LINE)
|
||||
|
||||
/**
|
||||
* enum of the elements of the page hierarchy, used in ResultIterator
|
||||
* to provide functions that operate on each level without having to
|
||||
* have 5x as many functions.
|
||||
*/
|
||||
enum PageIteratorLevel {
|
||||
RIL_BLOCK, // Block of text/image/separator line.
|
||||
RIL_PARA, // Paragraph within a block.
|
||||
RIL_TEXTLINE, // Line within a paragraph.
|
||||
RIL_WORD, // Word within a textline.
|
||||
RIL_SYMBOL // Symbol/character within a word.
|
||||
};
|
||||
|
||||
/**
|
||||
* JUSTIFICATION_UNKNONW
|
||||
* The alignment is not clearly one of the other options. This could happen
|
||||
* for example if there are only one or two lines of text or the text looks
|
||||
* like source code or poetry.
|
||||
*
|
||||
* NOTA BENE: Fully justified paragraphs (text aligned to both left and right
|
||||
* margins) are marked by Tesseract with JUSTIFICATION_LEFT if their text
|
||||
* is written with a left-to-right script and with JUSTIFICATION_RIGHT if
|
||||
* their text is written in a right-to-left script.
|
||||
*
|
||||
* Interpretation for text read in vertical lines:
|
||||
* "Left" is wherever the starting reading position is.
|
||||
*
|
||||
* JUSTIFICATION_LEFT
|
||||
* Each line, except possibly the first, is flush to the same left tab stop.
|
||||
*
|
||||
* JUSTIFICATION_CENTER
|
||||
* The text lines of the paragraph are centered about a line going
|
||||
* down through their middle of the text lines.
|
||||
*
|
||||
* JUSTIFICATION_RIGHT
|
||||
* Each line, except possibly the first, is flush to the same right tab stop.
|
||||
*/
|
||||
enum ParagraphJustification {
|
||||
JUSTIFICATION_UNKNOWN,
|
||||
JUSTIFICATION_LEFT,
|
||||
JUSTIFICATION_CENTER,
|
||||
JUSTIFICATION_RIGHT,
|
||||
};
|
||||
|
||||
/**
|
||||
* When Tesseract/Cube is initialized we can choose to instantiate/load/run
|
||||
* only the Tesseract part, only the Cube part or both along with the combiner.
|
||||
* The preference of which engine to use is stored in tessedit_ocr_engine_mode.
|
||||
*
|
||||
* ATTENTION: When modifying this enum, please make sure to make the
|
||||
* appropriate changes to all the enums mirroring it (e.g. OCREngine in
|
||||
* cityblock/workflow/detection/detection_storage.proto). Such enums will
|
||||
* mention the connection to OcrEngineMode in the comments.
|
||||
*/
|
||||
enum OcrEngineMode {
|
||||
OEM_TESSERACT_ONLY, // Run Tesseract only - fastest
|
||||
OEM_CUBE_ONLY, // Run Cube only - better accuracy, but slower
|
||||
OEM_TESSERACT_CUBE_COMBINED, // Run both and combine results - best accuracy
|
||||
OEM_DEFAULT // Specify this mode when calling init_*(),
|
||||
// to indicate that any of the above modes
|
||||
// should be automatically inferred from the
|
||||
// variables in the language-specific config,
|
||||
// command-line configs, or if not specified
|
||||
// in any of the above should be set to the
|
||||
// default OEM_TESSERACT_ONLY.
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCSTRUCT_PUBLICTYPES_H__
|
||||
@@ -1,237 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: resultiterator.h
|
||||
// Description: Iterator for tesseract results that is capable of
|
||||
// iterating in proper reading order over Bi Directional
|
||||
// (e.g. mixed Hebrew and English) text.
|
||||
// Author: David Eger
|
||||
// Created: Fri May 27 13:58:06 PST 2011
|
||||
//
|
||||
// (C) Copyright 2011, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_RESULT_ITERATOR_H__
|
||||
#define TESSERACT_CCMAIN_RESULT_ITERATOR_H__
|
||||
|
||||
#include "platform.h"
|
||||
#include "ltrresultiterator.h"
|
||||
#include "genericvector.h"
|
||||
|
||||
class BLOB_CHOICE_IT;
|
||||
class WERD_RES;
|
||||
class STRING;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
class TESS_API ResultIterator : public LTRResultIterator {
|
||||
public:
|
||||
static ResultIterator *StartOfParagraph(const LTRResultIterator &resit);
|
||||
|
||||
/**
|
||||
* ResultIterator is copy constructible!
|
||||
* The default copy constructor works just fine for us.
|
||||
*/
|
||||
virtual ~ResultIterator() {}
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
/**
|
||||
* Moves the iterator to point to the start of the page to begin
|
||||
* an iteration.
|
||||
*/
|
||||
virtual void Begin();
|
||||
|
||||
/**
|
||||
* Moves to the start of the next object at the given level in the
|
||||
* page hierarchy in the appropriate reading order and returns false if
|
||||
* the end of the page was reached.
|
||||
* NOTE that RIL_SYMBOL will skip non-text blocks, but all other
|
||||
* PageIteratorLevel level values will visit each non-text block once.
|
||||
* Think of non text blocks as containing a single para, with a single line,
|
||||
* with a single imaginary word.
|
||||
* Calls to Next with different levels may be freely intermixed.
|
||||
* This function iterates words in right-to-left scripts correctly, if
|
||||
* the appropriate language has been loaded into Tesseract.
|
||||
*/
|
||||
virtual bool Next(PageIteratorLevel level);
|
||||
|
||||
/**
|
||||
* IsAtBeginningOf() returns whether we're at the logical beginning of the
|
||||
* given level. (as opposed to ResultIterator's left-to-right top-to-bottom
|
||||
* order). Otherwise, this acts the same as PageIterator::IsAtBeginningOf().
|
||||
* For a full description, see pageiterator.h
|
||||
*/
|
||||
virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Implement PageIterator's IsAtFinalElement correctly in a BiDi context.
|
||||
* For instance, IsAtFinalElement(RIL_PARA, RIL_WORD) returns whether we
|
||||
* point at the last word in a paragraph. See PageIterator for full comment.
|
||||
*/
|
||||
virtual bool IsAtFinalElement(PageIteratorLevel level,
|
||||
PageIteratorLevel element) const;
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
|
||||
/**
|
||||
* Returns the null terminated UTF-8 encoded text string for the current
|
||||
* object at the given level. Use delete [] to free after use.
|
||||
*/
|
||||
virtual char* GetUTF8Text(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Return whether the current paragraph's dominant reading direction
|
||||
* is left-to-right (as opposed to right-to-left).
|
||||
*/
|
||||
bool ParagraphIsLtr() const;
|
||||
|
||||
// ============= Exposed only for testing =============.
|
||||
|
||||
/**
|
||||
* Yields the reading order as a sequence of indices and (optional)
|
||||
* meta-marks for a set of words (given left-to-right).
|
||||
* The meta marks are passed as negative values:
|
||||
* kMinorRunStart Start of minor direction text.
|
||||
* kMinorRunEnd End of minor direction text.
|
||||
* kComplexWord The next indexed word contains both left-to-right and
|
||||
* right-to-left characters and was treated as neutral.
|
||||
*
|
||||
* For example, suppose we have five words in a text line,
|
||||
* indexed [0,1,2,3,4] from the leftmost side of the text line.
|
||||
* The following are all believable reading_orders:
|
||||
*
|
||||
* Left-to-Right (in ltr paragraph):
|
||||
* { 0, 1, 2, 3, 4 }
|
||||
* Left-to-Right (in rtl paragraph):
|
||||
* { kMinorRunStart, 0, 1, 2, 3, 4, kMinorRunEnd }
|
||||
* Right-to-Left (in rtl paragraph):
|
||||
* { 4, 3, 2, 1, 0 }
|
||||
* Left-to-Right except for an RTL phrase in words 2, 3 in an ltr paragraph:
|
||||
* { 0, 1, kMinorRunStart, 3, 2, kMinorRunEnd, 4 }
|
||||
*/
|
||||
static void CalculateTextlineOrder(
|
||||
bool paragraph_is_ltr,
|
||||
const GenericVector<StrongScriptDirection> &word_dirs,
|
||||
GenericVectorEqEq<int> *reading_order);
|
||||
|
||||
static const int kMinorRunStart;
|
||||
static const int kMinorRunEnd;
|
||||
static const int kComplexWord;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* We presume the data associated with the given iterator will outlive us.
|
||||
* NB: This is private because it does something that is non-obvious:
|
||||
* it resets to the beginning of the paragraph instead of staying wherever
|
||||
* resit might have pointed.
|
||||
*/
|
||||
TESS_LOCAL explicit ResultIterator(const LTRResultIterator &resit);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calculates the current paragraph's dominant writing direction.
|
||||
* Typically, members should use current_paragraph_ltr_ instead.
|
||||
*/
|
||||
bool CurrentParagraphIsLtr() const;
|
||||
|
||||
/**
|
||||
* Returns word indices as measured from resit->RestartRow() = index 0
|
||||
* for the reading order of words within a textline given an iterator
|
||||
* into the middle of the text line.
|
||||
* In addition to non-negative word indices, the following negative values
|
||||
* may be inserted:
|
||||
* kMinorRunStart Start of minor direction text.
|
||||
* kMinorRunEnd End of minor direction text.
|
||||
* kComplexWord The previous word contains both left-to-right and
|
||||
* right-to-left characters and was treated as neutral.
|
||||
*/
|
||||
void CalculateTextlineOrder(bool paragraph_is_ltr,
|
||||
const LTRResultIterator &resit,
|
||||
GenericVectorEqEq<int> *indices) const;
|
||||
/** Same as above, but the caller's ssd gets filled in if ssd != NULL. */
|
||||
void CalculateTextlineOrder(bool paragraph_is_ltr,
|
||||
const LTRResultIterator &resit,
|
||||
GenericVector<StrongScriptDirection> *ssd,
|
||||
GenericVectorEqEq<int> *indices) const;
|
||||
|
||||
/**
|
||||
* What is the index of the current word in a strict left-to-right reading
|
||||
* of the row?
|
||||
*/
|
||||
int LTRWordIndex() const;
|
||||
|
||||
/**
|
||||
* Given an iterator pointing at a word, returns the logical reading order
|
||||
* of blob indices for the word.
|
||||
*/
|
||||
void CalculateBlobOrder(GenericVector<int> *blob_indices) const;
|
||||
|
||||
/** Precondition: current_paragraph_is_ltr_ is set. */
|
||||
void MoveToLogicalStartOfTextline();
|
||||
|
||||
/**
|
||||
* Precondition: current_paragraph_is_ltr_ and in_minor_direction_
|
||||
* are set.
|
||||
*/
|
||||
void MoveToLogicalStartOfWord();
|
||||
|
||||
/** Are we pointing at the final (reading order) symbol of the word? */
|
||||
bool IsAtFinalSymbolOfWord() const;
|
||||
|
||||
/** Are we pointing at the first (reading order) symbol of the word? */
|
||||
bool IsAtFirstSymbolOfWord() const;
|
||||
|
||||
/**
|
||||
* Append any extra marks that should be appended to this word when printed.
|
||||
* Mostly, these are Unicode BiDi control characters.
|
||||
*/
|
||||
void AppendSuffixMarks(STRING *text) const;
|
||||
|
||||
/** Appends the current word in reading order to the given buffer.*/
|
||||
void AppendUTF8WordText(STRING *text) const;
|
||||
|
||||
/**
|
||||
* Appends the text of the current text line, *assuming this iterator is
|
||||
* positioned at the beginning of the text line* This function
|
||||
* updates the iterator to point to the first position past the text line.
|
||||
* Each textline is terminated in a single newline character.
|
||||
* If the textline ends a paragraph, it gets a second terminal newline.
|
||||
*/
|
||||
void IterateAndAppendUTF8TextlineText(STRING *text);
|
||||
|
||||
/**
|
||||
* Appends the text of the current paragraph in reading order
|
||||
* to the given buffer.
|
||||
* Each textline is terminated in a single newline character, and the
|
||||
* paragraph gets an extra newline at the end.
|
||||
*/
|
||||
void AppendUTF8ParagraphText(STRING *text) const;
|
||||
|
||||
/** Returns whether the bidi_debug flag is set to at least min_level. */
|
||||
bool BidiDebug(int min_level) const;
|
||||
|
||||
bool current_paragraph_is_ltr_;
|
||||
|
||||
/**
|
||||
* Is the currently pointed-at character at the beginning of
|
||||
* a minor-direction run?
|
||||
*/
|
||||
bool at_beginning_of_minor_run_;
|
||||
|
||||
/** Is the currently pointed-at character in a minor-direction sequence? */
|
||||
bool in_minor_direction_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_RESULT_ITERATOR_H__
|
||||
@@ -1,43 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: serialis.h (Formerly serialmac.h)
|
||||
* Description: Inline routines and macros for serialisation functions
|
||||
* Author: Phil Cheatle
|
||||
* Created: Tue Oct 08 08:33:12 BST 1991
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef SERIALIS_H
|
||||
#define SERIALIS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "memry.h"
|
||||
#include "errcode.h"
|
||||
#include "fileerr.h"
|
||||
|
||||
// Switch endinan.
|
||||
extern DLLSYM uinT64 reverse64(uinT64);
|
||||
extern DLLSYM uinT32 reverse32(uinT32);
|
||||
extern DLLSYM uinT16 reverse16(uinT16);
|
||||
|
||||
/***********************************************************************
|
||||
QUOTE_IT MACRO DEFINITION
|
||||
===========================
|
||||
Replace <parm> with "<parm>". <parm> may be an arbitrary number of tokens
|
||||
***********************************************************************/
|
||||
|
||||
#define QUOTE_IT( parm ) #parm
|
||||
|
||||
#endif
|
||||
@@ -1,161 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: strngs.h (Formerly strings.h)
|
||||
* Description: STRING class definition.
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Feb 15 09:15:01 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef STRNGS_H
|
||||
#define STRNGS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "platform.h"
|
||||
#include "memry.h"
|
||||
|
||||
// STRING_IS_PROTECTED means that string[index] = X is invalid
|
||||
// because you have to go through strings interface to modify it.
|
||||
// This allows the string to ensure internal integrity and maintain
|
||||
// its own string length. Unfortunately this is not possible because
|
||||
// STRINGS are used as direct-manipulation data buffers for things
|
||||
// like length arrays and many places cast away the const on string()
|
||||
// to mutate the string. Turning this off means that internally we
|
||||
// cannot assume we know the strlen.
|
||||
#define STRING_IS_PROTECTED 0
|
||||
|
||||
template <typename T> class GenericVector;
|
||||
|
||||
class TESS_API STRING
|
||||
{
|
||||
public:
|
||||
STRING();
|
||||
STRING(const STRING &string);
|
||||
STRING(const char *string);
|
||||
~STRING ();
|
||||
|
||||
// Writes to the given file. Returns false in case of error.
|
||||
bool Serialize(FILE* fp) const;
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool DeSerialize(bool swap, FILE* fp);
|
||||
|
||||
BOOL8 contains(const char c) const;
|
||||
inT32 length() const;
|
||||
inT32 size() const { return length(); }
|
||||
const char *string() const;
|
||||
|
||||
inline char* strdup() const {
|
||||
inT32 len = length() + 1;
|
||||
return strncpy(new char[len], GetCStr(), len);
|
||||
}
|
||||
|
||||
#if STRING_IS_PROTECTED
|
||||
const char &operator[] (inT32 index) const;
|
||||
// len is number of chars in s to insert starting at index in this string
|
||||
void insert_range(inT32 index, const char*s, int len);
|
||||
void erase_range(inT32 index, int len);
|
||||
#else
|
||||
char &operator[] (inT32 index) const;
|
||||
#endif
|
||||
void split(const char c, GenericVector<STRING> *splited);
|
||||
void truncate_at(inT32 index);
|
||||
|
||||
BOOL8 operator== (const STRING & string) const;
|
||||
BOOL8 operator!= (const STRING & string) const;
|
||||
BOOL8 operator!= (const char *string) const;
|
||||
|
||||
STRING & operator= (const char *string);
|
||||
STRING & operator= (const STRING & string);
|
||||
|
||||
STRING operator+ (const STRING & string) const;
|
||||
STRING operator+ (const char ch) const;
|
||||
|
||||
STRING & operator+= (const char *string);
|
||||
STRING & operator+= (const STRING & string);
|
||||
STRING & operator+= (const char ch);
|
||||
|
||||
// Assignment for strings which are not null-terminated.
|
||||
void assign(const char *cstr, int len);
|
||||
|
||||
// Appends the given string and int (as a %d) to this.
|
||||
// += cannot be used for ints as there as a char += operator that would
|
||||
// be ambiguous, and ints usually need a string before or between them
|
||||
// anyway.
|
||||
void add_str_int(const char* str, int number);
|
||||
|
||||
// ensure capcaity but keep pointer encapsulated
|
||||
inline void ensure(inT32 min_capacity) { ensure_cstr(min_capacity); }
|
||||
|
||||
private:
|
||||
typedef struct STRING_HEADER {
|
||||
// How much space was allocated in the string buffer for char data.
|
||||
int capacity_;
|
||||
|
||||
// used_ is how much of the capacity is currently being used,
|
||||
// including a '\0' terminator.
|
||||
//
|
||||
// If used_ is 0 then string is NULL (not even the '\0')
|
||||
// else if used_ > 0 then it is strlen() + 1 (because it includes '\0')
|
||||
// else strlen is >= 0 (not NULL) but needs to be computed.
|
||||
// this condition is set when encapsulation is violated because
|
||||
// an API returned a mutable string.
|
||||
//
|
||||
// capacity_ - used_ = excess capacity that the string can grow
|
||||
// without reallocating
|
||||
mutable int used_;
|
||||
} STRING_HEADER;
|
||||
|
||||
// To preserve the behavior of the old serialization, we only have space
|
||||
// for one pointer in this structure. So we are embedding a data structure
|
||||
// at the start of the storage that will hold additional state variables,
|
||||
// then storing the actual string contents immediately after.
|
||||
STRING_HEADER* data_;
|
||||
|
||||
// returns the header part of the storage
|
||||
inline STRING_HEADER* GetHeader() {
|
||||
return data_;
|
||||
}
|
||||
inline const STRING_HEADER* GetHeader() const {
|
||||
return data_;
|
||||
}
|
||||
|
||||
// returns the string data part of storage
|
||||
inline char* GetCStr() {
|
||||
return ((char *)data_) + sizeof(STRING_HEADER);
|
||||
};
|
||||
|
||||
inline const char* GetCStr() const {
|
||||
return ((const char *)data_) + sizeof(STRING_HEADER);
|
||||
};
|
||||
inline bool InvariantOk() const {
|
||||
#if STRING_IS_PROTECTED
|
||||
return (GetHeader()->used_ == 0) ?
|
||||
(string() == NULL) : (GetHeader()->used_ == (strlen(string()) + 1));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Ensure string has requested capacity as optimization
|
||||
// to avoid unnecessary reallocations.
|
||||
// The return value is a cstr buffer with at least requested capacity
|
||||
char* ensure_cstr(inT32 min_capacity);
|
||||
|
||||
void FixHeader() const; // make used_ non-negative, even if const
|
||||
|
||||
char* AllocData(int used, int capacity);
|
||||
void DiscardData();
|
||||
};
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,191 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: thresholder.h
|
||||
// Description: Base API for thresolding images in tesseract.
|
||||
// Author: Ray Smith
|
||||
// Created: Mon May 12 11:00:15 PDT 2008
|
||||
//
|
||||
// (C) Copyright 2008, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_THRESHOLDER_H__
|
||||
#define TESSERACT_CCMAIN_THRESHOLDER_H__
|
||||
|
||||
class IMAGE;
|
||||
struct Pix;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
/// Base class for all tesseract image thresholding classes.
|
||||
/// Specific classes can add new thresholding methods by
|
||||
/// overriding ThresholdToPix.
|
||||
/// Each instance deals with a single image, but the design is intended to
|
||||
/// be useful for multiple calls to SetRectangle and ThresholdTo* if
|
||||
/// desired.
|
||||
class ImageThresholder {
|
||||
public:
|
||||
ImageThresholder();
|
||||
virtual ~ImageThresholder();
|
||||
|
||||
/// Destroy the Pix if there is one, freeing memory.
|
||||
virtual void Clear();
|
||||
|
||||
/// Return true if no image has been set.
|
||||
bool IsEmpty() const;
|
||||
|
||||
/// SetImage makes a copy of only the metadata, not the underlying
|
||||
/// image buffer. It promises to treat the source as read-only in either case,
|
||||
/// but in return assumes that the Pix or image buffer remain valid
|
||||
/// throughout the life of the ImageThresholder.
|
||||
/// Greyscale of 8 and color of 24 or 32 bits per pixel may be given.
|
||||
/// Palette color images will not work properly and must be converted to
|
||||
/// 24 bit.
|
||||
/// Binary images of 1 bit per pixel may also be given but they must be
|
||||
/// byte packed with the MSB of the first byte being the first pixel, and a
|
||||
/// one pixel is WHITE. For binary images set bytes_per_pixel=0.
|
||||
void SetImage(const unsigned char* imagedata, int width, int height,
|
||||
int bytes_per_pixel, int bytes_per_line);
|
||||
|
||||
/// Store the coordinates of the rectangle to process for later use.
|
||||
/// Doesn't actually do any thresholding.
|
||||
void SetRectangle(int left, int top, int width, int height);
|
||||
|
||||
/// Get enough parameters to be able to rebuild bounding boxes in the
|
||||
/// original image (not just within the rectangle).
|
||||
/// Left and top are enough with top-down coordinates, but
|
||||
/// the height of the rectangle and the image are needed for bottom-up.
|
||||
virtual void GetImageSizes(int* left, int* top, int* width, int* height,
|
||||
int* imagewidth, int* imageheight);
|
||||
|
||||
/// Return true if the source image is color.
|
||||
bool IsColor() const {
|
||||
return image_bytespp_ >= 3;
|
||||
}
|
||||
|
||||
/// Returns true if the source image is binary.
|
||||
bool IsBinary() const {
|
||||
return image_bytespp_ == 0;
|
||||
}
|
||||
|
||||
int GetScaleFactor() const {
|
||||
return scale_;
|
||||
}
|
||||
|
||||
// Set the resolution of the source image in pixels per inch.
|
||||
// This should be called right after SetImage(), and will let us return
|
||||
// appropriate font sizes for the text.
|
||||
void SetSourceYResolution(int ppi) {
|
||||
yres_ = ppi;
|
||||
estimated_res_ = ppi;
|
||||
}
|
||||
int GetSourceYResolution() const {
|
||||
return yres_;
|
||||
}
|
||||
int GetScaledYResolution() const {
|
||||
return scale_ * yres_;
|
||||
}
|
||||
// Set the resolution of the source image in pixels per inch, as estimated
|
||||
// by the thresholder from the text size found during thresholding.
|
||||
// This value will be used to set internal size thresholds during recognition
|
||||
// and will not influence the output "point size." The default value is
|
||||
// the same as the source resolution. (yres_)
|
||||
void SetEstimatedResolution(int ppi) {
|
||||
estimated_res_ = ppi;
|
||||
}
|
||||
// Returns the estimated resolution, including any active scaling.
|
||||
// This value will be used to set internal size thresholds during recognition.
|
||||
int GetScaledEstimatedResolution() const {
|
||||
return scale_ * estimated_res_;
|
||||
}
|
||||
|
||||
/// Pix vs raw, which to use?
|
||||
/// Implementations should provide the ability to source and target Pix
|
||||
/// where possible. A future version of Tesseract may choose to use Pix
|
||||
/// as its internal representation and discard IMAGE altogether.
|
||||
/// Because of that, an implementation that sources and targets Pix may end up
|
||||
/// with less copies than an implementation that does not.
|
||||
/// NOTE: Opposite to SetImage for raw images, SetImage for Pix clones its
|
||||
/// input, so the source pix may be pixDestroyed immediately after.
|
||||
void SetImage(const Pix* pix);
|
||||
|
||||
/// Threshold the source image as efficiently as possible to the output Pix.
|
||||
/// Creates a Pix and sets pix to point to the resulting pointer.
|
||||
/// Caller must use pixDestroy to free the created Pix.
|
||||
virtual void ThresholdToPix(Pix** pix);
|
||||
|
||||
/// Get a clone/copy of the source image rectangle.
|
||||
/// The returned Pix must be pixDestroyed.
|
||||
/// This function will be used in the future by the page layout analysis, and
|
||||
/// the layout analysis that uses it will only be available with Leptonica,
|
||||
/// so there is no raw equivalent.
|
||||
Pix* GetPixRect();
|
||||
|
||||
/// Get a clone/copy of the source image rectangle, reduced to greyscale.
|
||||
/// The returned Pix must be pixDestroyed.
|
||||
/// This function will be used in the future by the page layout analysis, and
|
||||
/// the layout analysis that uses it will only be available with Leptonica,
|
||||
/// so there is no raw equivalent.
|
||||
Pix* GetPixRectGrey();
|
||||
|
||||
protected:
|
||||
// ----------------------------------------------------------------------
|
||||
// Utility functions that may be useful components for other thresholders.
|
||||
|
||||
/// Common initialization shared between SetImage methods.
|
||||
virtual void Init();
|
||||
|
||||
/// Return true if we are processing the full image.
|
||||
bool IsFullImage() const {
|
||||
return rect_left_ == 0 && rect_top_ == 0 &&
|
||||
rect_width_ == image_width_ && rect_height_ == image_height_;
|
||||
}
|
||||
|
||||
/// Otsu threshold the rectangle, taking everything except the image buffer
|
||||
/// pointer from the class, to the output Pix.
|
||||
void OtsuThresholdRectToPix(const unsigned char* imagedata,
|
||||
int bytes_per_pixel, int bytes_per_line,
|
||||
Pix** pix) const;
|
||||
|
||||
/// Threshold the rectangle, taking everything except the image buffer pointer
|
||||
/// from the class, using thresholds/hi_values to the output IMAGE.
|
||||
void ThresholdRectToPix(const unsigned char* imagedata,
|
||||
int bytes_per_pixel, int bytes_per_line,
|
||||
const int* thresholds, const int* hi_values,
|
||||
Pix** pix) const;
|
||||
|
||||
/// Copy the raw image rectangle, taking all data from the class, to the Pix.
|
||||
void RawRectToPix(Pix** pix) const;
|
||||
|
||||
protected:
|
||||
/// Clone or other copy of the source Pix.
|
||||
/// The pix will always be PixDestroy()ed on destruction of the class.
|
||||
Pix* pix_;
|
||||
/// Exactly one of pix_ and image_data_ is not NULL.
|
||||
const unsigned char* image_data_; //< Raw source image.
|
||||
|
||||
int image_width_; //< Width of source image/pix.
|
||||
int image_height_; //< Height of source image/pix.
|
||||
int image_bytespp_; //< Bytes per pixel of source image/pix.
|
||||
int image_bytespl_; //< Bytes per line of source image/pix.
|
||||
// Limits of image rectangle to be processed.
|
||||
int scale_; //< Scale factor from original image.
|
||||
int yres_; //< y pixels/inch in source image.
|
||||
int estimated_res_; //< Resolution estimate from text size.
|
||||
int rect_left_;
|
||||
int rect_top_;
|
||||
int rect_width_;
|
||||
int rect_height_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_THRESHOLDER_H__
|
||||
@@ -1,93 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: unichar.h
|
||||
// Description: Unicode character/ligature class.
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Jun 28 17:05:01 PDT 2006
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_UNICHAR_H__
|
||||
#define TESSERACT_CCUTIL_UNICHAR_H__
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
// Maximum number of characters that can be stored in a UNICHAR. Must be
|
||||
// at least 4. Must not exceed 31 without changing the coding of length.
|
||||
#define UNICHAR_LEN 30
|
||||
|
||||
// A UNICHAR_ID is the unique id of a unichar.
|
||||
typedef int UNICHAR_ID;
|
||||
|
||||
// A variable to indicate an invalid or uninitialized unichar id.
|
||||
static const int INVALID_UNICHAR_ID = -1;
|
||||
// A special unichar that corresponds to INVALID_UNICHAR_ID.
|
||||
static const char INVALID_UNICHAR[] = "__INVALID_UNICHAR__";
|
||||
|
||||
enum StrongScriptDirection {
|
||||
DIR_NEUTRAL = 0, // Text contains only neutral characters.
|
||||
DIR_LEFT_TO_RIGHT = 1, // Text contains no Right-to-Left characters.
|
||||
DIR_RIGHT_TO_LEFT = 2, // Text contains no Left-to-Right characters.
|
||||
DIR_MIX = 3, // Text contains a mixture of left-to-right
|
||||
// and right-to-left characters.
|
||||
};
|
||||
|
||||
// The UNICHAR class holds a single classification result. This may be
|
||||
// a single Unicode character (stored as between 1 and 4 utf8 bytes) or
|
||||
// multple Unicode characters representing the NFKC expansion of a ligature
|
||||
// such as fi, ffl etc. These are also stored as utf8.
|
||||
class UNICHAR {
|
||||
public:
|
||||
UNICHAR() {
|
||||
memset(chars, 0, UNICHAR_LEN);
|
||||
}
|
||||
|
||||
// Construct from a utf8 string. If len<0 then the string is null terminated.
|
||||
// If the string is too long to fit in the UNICHAR then it takes only what
|
||||
// will fit.
|
||||
UNICHAR(const char* utf8_str, int len);
|
||||
|
||||
// Construct from a single UCS4 character.
|
||||
explicit UNICHAR(int unicode);
|
||||
|
||||
// Default copy constructor and operator= are OK.
|
||||
|
||||
// Get the first character as UCS-4.
|
||||
int first_uni() const;
|
||||
|
||||
// Get the length of the UTF8 string.
|
||||
int utf8_len() const {
|
||||
int len = chars[UNICHAR_LEN - 1];
|
||||
return len >=0 && len < UNICHAR_LEN ? len : UNICHAR_LEN;
|
||||
}
|
||||
|
||||
// Get a UTF8 string, but NOT NULL terminated.
|
||||
const char* utf8() const {
|
||||
return chars;
|
||||
}
|
||||
|
||||
// Get a terminated UTF8 string: Must delete[] it after use.
|
||||
char* utf8_str() const;
|
||||
|
||||
// Get the number of bytes in the first character of the given utf8 string.
|
||||
static int utf8_step(const char* utf8_str);
|
||||
|
||||
private:
|
||||
// A UTF-8 representation of 1 or more Unicode characters.
|
||||
// The last element (chars[UNICHAR_LEN - 1]) is a length if
|
||||
// its value < UNICHAR_LEN, otherwise it is a genuine character.
|
||||
char chars[UNICHAR_LEN];
|
||||
};
|
||||
|
||||
#endif // TESSERACT_CCUTIL_UNICHAR_H__
|
||||
@@ -1,82 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: unicharmap.h
|
||||
// Description: Unicode character/ligature to integer id class.
|
||||
// Author: Thomas Kielbus
|
||||
// Created: Wed Jun 28 17:05:01 PDT 2006
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_UNICHARMAP_H__
|
||||
#define TESSERACT_CCUTIL_UNICHARMAP_H__
|
||||
|
||||
#include "unichar.h"
|
||||
|
||||
// A UNICHARMAP stores unique unichars. Each of them is associated with one
|
||||
// UNICHAR_ID.
|
||||
class UNICHARMAP {
|
||||
public:
|
||||
|
||||
// Create an empty UNICHARMAP
|
||||
UNICHARMAP();
|
||||
|
||||
~UNICHARMAP();
|
||||
|
||||
// Insert the given unichar represention in the UNICHARMAP and associate it
|
||||
// with the given id. The length of the representation MUST be non-zero.
|
||||
void insert(const char* const unichar_repr, UNICHAR_ID id);
|
||||
|
||||
// Return the id associated with the given unichar representation,
|
||||
// this representation MUST exist within the UNICHARMAP.
|
||||
// The length of the representation MUST be non-zero.
|
||||
UNICHAR_ID unichar_to_id(const char* const unichar_repr) const;
|
||||
|
||||
// Return the id associated with the given unichar representation,
|
||||
// this representation MUST exist within the UNICHARMAP. The first
|
||||
// length characters (maximum) from unichar_repr are used. The length
|
||||
// MUST be non-zero.
|
||||
UNICHAR_ID unichar_to_id(const char* const unichar_repr, int length) const;
|
||||
|
||||
// Return true if the given unichar representation is already present in the
|
||||
// UNICHARMAP. The length of the representation MUST be non-zero.
|
||||
bool contains(const char* const unichar_repr) const;
|
||||
|
||||
// Return true if the given unichar representation is already present in the
|
||||
// UNICHARMAP. The first length characters (maximum) from unichar_repr are
|
||||
// used. The length MUST be non-zero.
|
||||
bool contains(const char* const unichar_repr, int length) const;
|
||||
|
||||
// Return the minimum number of characters that must be used from this string
|
||||
// to obtain a match in the UNICHARMAP.
|
||||
int minmatch(const char* const unichar_repr) const;
|
||||
|
||||
// Clear the UNICHARMAP. All previous data is lost.
|
||||
void clear();
|
||||
|
||||
private:
|
||||
|
||||
// The UNICHARMAP is represented as a tree whose nodes are of type
|
||||
// UNICHARMAP_NODE.
|
||||
struct UNICHARMAP_NODE {
|
||||
|
||||
UNICHARMAP_NODE();
|
||||
~UNICHARMAP_NODE();
|
||||
|
||||
UNICHARMAP_NODE* children;
|
||||
UNICHAR_ID id;
|
||||
};
|
||||
|
||||
UNICHARMAP_NODE* nodes;
|
||||
};
|
||||
|
||||
#endif // TESSERACT_CCUTIL_UNICHARMAP_H__
|
||||
@@ -1,884 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: unicharset.h
|
||||
// Description: Unicode character/ligature set class.
|
||||
// Author: Thomas Kielbus
|
||||
// Created: Wed Jun 28 17:05:01 PDT 2006
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_UNICHARSET_H__
|
||||
#define TESSERACT_CCUTIL_UNICHARSET_H__
|
||||
|
||||
#include "errcode.h"
|
||||
#include "helpers.h"
|
||||
#include "strngs.h"
|
||||
#include "tesscallback.h"
|
||||
#include "unichar.h"
|
||||
#include "unicharmap.h"
|
||||
|
||||
class CHAR_FRAGMENT {
|
||||
public:
|
||||
// Minimum number of characters used for fragment representation.
|
||||
static const int kMinLen = 6;
|
||||
// Maximum number of characters used for fragment representation.
|
||||
static const int kMaxLen = 3 + UNICHAR_LEN + 2;
|
||||
// Maximum number of fragments per character.
|
||||
static const int kMaxChunks = 5;
|
||||
|
||||
// Setters and Getters.
|
||||
inline void set_all(const char *unichar, int pos, int total, bool natural) {
|
||||
set_unichar(unichar);
|
||||
set_pos(pos);
|
||||
set_total(total);
|
||||
set_natural(natural);
|
||||
}
|
||||
inline void set_unichar(const char *uch) {
|
||||
strncpy(this->unichar, uch, UNICHAR_LEN);
|
||||
this->unichar[UNICHAR_LEN] = '\0';
|
||||
}
|
||||
inline void set_pos(int p) { this->pos = p; }
|
||||
inline void set_total(int t) { this->total = t; }
|
||||
inline const char* get_unichar() const { return this->unichar; }
|
||||
inline int get_pos() const { return this->pos; }
|
||||
inline int get_total() const { return this->total; }
|
||||
|
||||
// Returns the string that represents a fragment
|
||||
// with the given unichar, pos and total.
|
||||
static STRING to_string(const char *unichar, int pos, int total,
|
||||
bool natural);
|
||||
// Returns the string that represents this fragment.
|
||||
STRING to_string() const {
|
||||
return to_string(unichar, pos, total, natural);
|
||||
}
|
||||
|
||||
// Checks whether a fragment has the same unichar,
|
||||
// position and total as the given inputs.
|
||||
inline bool equals(const char *other_unichar,
|
||||
int other_pos, int other_total) const {
|
||||
return (strcmp(this->unichar, other_unichar) == 0 &&
|
||||
this->pos == other_pos && this->total == other_total);
|
||||
}
|
||||
inline bool equals(const CHAR_FRAGMENT *other) const {
|
||||
return this->equals(other->get_unichar(),
|
||||
other->get_pos(),
|
||||
other->get_total());
|
||||
}
|
||||
|
||||
// Checks whether a given fragment is a continuation of this fragment.
|
||||
// Assumes that the given fragment pointer is not NULL.
|
||||
inline bool is_continuation_of(const CHAR_FRAGMENT *fragment) const {
|
||||
return (strcmp(this->unichar, fragment->get_unichar()) == 0 &&
|
||||
this->total == fragment->get_total() &&
|
||||
this->pos == fragment->get_pos() + 1);
|
||||
}
|
||||
|
||||
// Returns true if this fragment is a beginning fragment.
|
||||
inline bool is_beginning() const { return this->pos == 0; }
|
||||
|
||||
// Returns true if this fragment is an ending fragment.
|
||||
inline bool is_ending() const { return this->pos == this->total-1; }
|
||||
|
||||
// Returns true if the fragment was a separate component to begin with,
|
||||
// ie did not need chopping to be isolated, but may have been separated
|
||||
// out from a multi-outline blob.
|
||||
inline bool is_natural() const { return natural; }
|
||||
void set_natural(bool value) { natural = value; }
|
||||
|
||||
// Parses the string to see whether it represents a character fragment
|
||||
// (rather than a regular character). If so, allocates memory for a new
|
||||
// CHAR_FRAGMENT instance and fills it in with the corresponding fragment
|
||||
// information. Fragments are of the form:
|
||||
// |m|1|2, meaning chunk 1 of 2 of character m, or
|
||||
// |:|1n2, meaning chunk 1 of 2 of character :, and no chopping was needed
|
||||
// to divide the parts, as they were already separate connected components.
|
||||
//
|
||||
// If parsing succeeded returns the pointer to the allocated CHAR_FRAGMENT
|
||||
// instance, otherwise (if the string does not represent a fragment or it
|
||||
// looks like it does, but parsing it as a fragment fails) returns NULL.
|
||||
//
|
||||
// Note: The caller is responsible for deallocating memory
|
||||
// associated with the returned pointer.
|
||||
static CHAR_FRAGMENT *parse_from_string(const char *str);
|
||||
|
||||
private:
|
||||
char unichar[UNICHAR_LEN + 1];
|
||||
// True if the fragment was a separate component to begin with,
|
||||
// ie did not need chopping to be isolated, but may have been separated
|
||||
// out from a multi-outline blob.
|
||||
bool natural;
|
||||
inT16 pos; // fragment position in the character
|
||||
inT16 total; // total number of fragments in the character
|
||||
};
|
||||
|
||||
// The UNICHARSET class is an utility class for Tesseract that holds the
|
||||
// set of characters that are used by the engine. Each character is identified
|
||||
// by a unique number, from 0 to (size - 1).
|
||||
class UNICHARSET {
|
||||
public:
|
||||
// Custom list of characters and their ligature forms (UTF8)
|
||||
// These map to unicode values in the private use area (PUC) and are supported
|
||||
// by only few font families (eg. Wyld, Adobe Caslon Pro).
|
||||
static const char* kCustomLigatures[][2];
|
||||
|
||||
// ICU 2.0 UCharDirection enum (from third_party/icu/include/unicode/uchar.h)
|
||||
enum Direction {
|
||||
U_LEFT_TO_RIGHT = 0,
|
||||
U_RIGHT_TO_LEFT = 1,
|
||||
U_EUROPEAN_NUMBER = 2,
|
||||
U_EUROPEAN_NUMBER_SEPARATOR = 3,
|
||||
U_EUROPEAN_NUMBER_TERMINATOR = 4,
|
||||
U_ARABIC_NUMBER = 5,
|
||||
U_COMMON_NUMBER_SEPARATOR = 6,
|
||||
U_BLOCK_SEPARATOR = 7,
|
||||
U_SEGMENT_SEPARATOR = 8,
|
||||
U_WHITE_SPACE_NEUTRAL = 9,
|
||||
U_OTHER_NEUTRAL = 10,
|
||||
U_LEFT_TO_RIGHT_EMBEDDING = 11,
|
||||
U_LEFT_TO_RIGHT_OVERRIDE = 12,
|
||||
U_RIGHT_TO_LEFT_ARABIC = 13,
|
||||
U_RIGHT_TO_LEFT_EMBEDDING = 14,
|
||||
U_RIGHT_TO_LEFT_OVERRIDE = 15,
|
||||
U_POP_DIRECTIONAL_FORMAT = 16,
|
||||
U_DIR_NON_SPACING_MARK = 17,
|
||||
U_BOUNDARY_NEUTRAL = 18,
|
||||
U_CHAR_DIRECTION_COUNT
|
||||
};
|
||||
|
||||
// Create an empty UNICHARSET
|
||||
UNICHARSET();
|
||||
|
||||
~UNICHARSET();
|
||||
|
||||
// Return the UNICHAR_ID of a given unichar representation within the
|
||||
// UNICHARSET.
|
||||
const UNICHAR_ID unichar_to_id(const char* const unichar_repr) const;
|
||||
|
||||
// Return the UNICHAR_ID of a given unichar representation within the
|
||||
// UNICHARSET. Only the first length characters from unichar_repr are used.
|
||||
const UNICHAR_ID unichar_to_id(const char* const unichar_repr,
|
||||
int length) const;
|
||||
|
||||
// Return the minimum number of bytes that matches a legal UNICHAR_ID,
|
||||
// while leaving a legal UNICHAR_ID afterwards. In other words, if there
|
||||
// is both a short and a long match to the string, return the length that
|
||||
// ensures there is a legal match after it.
|
||||
int step(const char* str) const;
|
||||
|
||||
// Return whether the given UTF-8 string is encodable with this UNICHARSET.
|
||||
// If not encodable, write the first byte offset which cannot be converted
|
||||
// into the second (return) argument.
|
||||
bool encodable_string(const char *str, int *first_bad_position) const;
|
||||
|
||||
// Return the unichar representation corresponding to the given UNICHAR_ID
|
||||
// within the UNICHARSET.
|
||||
const char* const id_to_unichar(UNICHAR_ID id) const;
|
||||
|
||||
// Return the UTF8 representation corresponding to the given UNICHAR_ID after
|
||||
// resolving any private encodings internal to Tesseract. This method is
|
||||
// preferrable to id_to_unichar for outputting text that will be visible to
|
||||
// external applications.
|
||||
const char* const id_to_unichar_ext(UNICHAR_ID id) const;
|
||||
|
||||
// Return a STRING that reformats the utf8 str into the str followed
|
||||
// by its hex unicodes.
|
||||
static STRING debug_utf8_str(const char* str);
|
||||
|
||||
// Return a STRING containing debug information on the unichar, including
|
||||
// the id_to_unichar, its hex unicodes and the properties.
|
||||
STRING debug_str(UNICHAR_ID id) const;
|
||||
STRING debug_str(const char * unichar_repr) const {
|
||||
return debug_str(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Add a unichar representation to the set.
|
||||
void unichar_insert(const char* const unichar_repr);
|
||||
|
||||
// Return true if the given unichar id exists within the set.
|
||||
// Relies on the fact that unichar ids are contiguous in the unicharset.
|
||||
bool contains_unichar_id(UNICHAR_ID unichar_id) const {
|
||||
return unichar_id != INVALID_UNICHAR_ID && unichar_id < size_used &&
|
||||
unichar_id >= 0;
|
||||
}
|
||||
|
||||
// Return true if the given unichar representation exists within the set.
|
||||
bool contains_unichar(const char* const unichar_repr) const;
|
||||
bool contains_unichar(const char* const unichar_repr, int length) const;
|
||||
|
||||
// Return true if the given unichar representation corresponds to the given
|
||||
// UNICHAR_ID within the set.
|
||||
bool eq(UNICHAR_ID unichar_id, const char* const unichar_repr) const;
|
||||
|
||||
// Delete CHAR_FRAGMENTs stored in properties of unichars array.
|
||||
void delete_pointers_in_unichars() {
|
||||
for (int i = 0; i < size_used; ++i) {
|
||||
if (unichars[i].properties.fragment != NULL) {
|
||||
delete unichars[i].properties.fragment;
|
||||
unichars[i].properties.fragment = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the UNICHARSET (all the previous data is lost).
|
||||
void clear() {
|
||||
if (script_table != NULL) {
|
||||
for (int i = 0; i < script_table_size_used; ++i)
|
||||
delete[] script_table[i];
|
||||
delete[] script_table;
|
||||
script_table = NULL;
|
||||
script_table_size_used = 0;
|
||||
}
|
||||
if (unichars != NULL) {
|
||||
delete_pointers_in_unichars();
|
||||
delete[] unichars;
|
||||
unichars = NULL;
|
||||
}
|
||||
script_table_size_reserved = 0;
|
||||
size_reserved = 0;
|
||||
size_used = 0;
|
||||
ids.clear();
|
||||
top_bottom_set_ = false;
|
||||
script_has_upper_lower_ = false;
|
||||
script_has_xheight_ = false;
|
||||
null_sid_ = 0;
|
||||
common_sid_ = 0;
|
||||
latin_sid_ = 0;
|
||||
cyrillic_sid_ = 0;
|
||||
greek_sid_ = 0;
|
||||
han_sid_ = 0;
|
||||
hiragana_sid_ = 0;
|
||||
katakana_sid_ = 0;
|
||||
}
|
||||
|
||||
// Return the size of the set (the number of different UNICHAR it holds).
|
||||
int size() const {
|
||||
return size_used;
|
||||
}
|
||||
|
||||
// Reserve enough memory space for the given number of UNICHARS
|
||||
void reserve(int unichars_number);
|
||||
|
||||
// Opens the file indicated by filename and saves unicharset to that file.
|
||||
// Returns true if the operation is successful.
|
||||
bool save_to_file(const char * const filename) const {
|
||||
FILE* file = fopen(filename, "w+b");
|
||||
if (file == NULL) return false;
|
||||
bool result = save_to_file(file);
|
||||
fclose(file);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Saves the content of the UNICHARSET to the given file.
|
||||
// Returns true if the operation is successful.
|
||||
bool save_to_file(FILE *file) const;
|
||||
|
||||
// Load a unicharset from a unicharset file that has been loaded into
|
||||
// the given memory buffer.
|
||||
// Returns true if the operation is successful.
|
||||
bool load_from_inmemory_file(const char* const memory, int mem_size,
|
||||
bool skip_fragments);
|
||||
// Returns true if the operation is successful.
|
||||
bool load_from_inmemory_file(const char* const memory, int mem_size) {
|
||||
return load_from_inmemory_file(memory, mem_size, false);
|
||||
}
|
||||
|
||||
// Opens the file indicated by filename and loads the UNICHARSET
|
||||
// from the given file. The previous data is lost.
|
||||
// Returns true if the operation is successful.
|
||||
bool load_from_file(const char* const filename, bool skip_fragments) {
|
||||
FILE* file = fopen(filename, "rb");
|
||||
if (file == NULL) return false;
|
||||
bool result = load_from_file(file, skip_fragments);
|
||||
fclose(file);
|
||||
return result;
|
||||
}
|
||||
// returns true if the operation is successful.
|
||||
bool load_from_file(const char* const filename) {
|
||||
return load_from_file(filename, false);
|
||||
}
|
||||
|
||||
// Loads the UNICHARSET from the given file. The previous data is lost.
|
||||
// Returns true if the operation is successful.
|
||||
bool load_from_file(FILE *file, bool skip_fragments);
|
||||
bool load_from_file(FILE *file) { return load_from_file(file, false); }
|
||||
|
||||
// Sets up internal data after loading the file, based on the char
|
||||
// properties. Called from load_from_file, but also needs to be run
|
||||
// during set_unicharset_properties.
|
||||
void post_load_setup();
|
||||
|
||||
// Returns true if right_to_left scripts are significant in the unicharset,
|
||||
// but without being so sensitive that "universal" unicharsets containing
|
||||
// characters from many scripts, like orientation and script detection,
|
||||
// look like they are right_to_left.
|
||||
bool major_right_to_left() const;
|
||||
|
||||
// Set a whitelist and/or blacklist of characters to recognize.
|
||||
// An empty or NULL whitelist enables everything (minus any blacklist).
|
||||
// An empty or NULL blacklist disables nothing.
|
||||
// The blacklist overrides the whitelist.
|
||||
// Each list is a string of utf8 character strings. Boundaries between
|
||||
// unicharset units are worked out automatically, and characters not in
|
||||
// the unicharset are silently ignored.
|
||||
void set_black_and_whitelist(const char* blacklist, const char* whitelist);
|
||||
|
||||
// Set the isalpha property of the given unichar to the given value.
|
||||
void set_isalpha(UNICHAR_ID unichar_id, bool value) {
|
||||
unichars[unichar_id].properties.isalpha = value;
|
||||
}
|
||||
|
||||
// Set the islower property of the given unichar to the given value.
|
||||
void set_islower(UNICHAR_ID unichar_id, bool value) {
|
||||
unichars[unichar_id].properties.islower = value;
|
||||
}
|
||||
|
||||
// Set the isupper property of the given unichar to the given value.
|
||||
void set_isupper(UNICHAR_ID unichar_id, bool value) {
|
||||
unichars[unichar_id].properties.isupper = value;
|
||||
}
|
||||
|
||||
// Set the isdigit property of the given unichar to the given value.
|
||||
void set_isdigit(UNICHAR_ID unichar_id, bool value) {
|
||||
unichars[unichar_id].properties.isdigit = value;
|
||||
}
|
||||
|
||||
// Set the ispunctuation property of the given unichar to the given value.
|
||||
void set_ispunctuation(UNICHAR_ID unichar_id, bool value) {
|
||||
unichars[unichar_id].properties.ispunctuation = value;
|
||||
}
|
||||
|
||||
// Set the isngram property of the given unichar to the given value.
|
||||
void set_isngram(UNICHAR_ID unichar_id, bool value) {
|
||||
unichars[unichar_id].properties.isngram = value;
|
||||
}
|
||||
|
||||
// Set the script name of the given unichar to the given value.
|
||||
// Value is copied and thus can be a temporary;
|
||||
void set_script(UNICHAR_ID unichar_id, const char* value) {
|
||||
unichars[unichar_id].properties.script_id = add_script(value);
|
||||
}
|
||||
|
||||
// Set other_case unichar id in the properties for the given unichar id.
|
||||
void set_other_case(UNICHAR_ID unichar_id, UNICHAR_ID other_case) {
|
||||
unichars[unichar_id].properties.other_case = other_case;
|
||||
}
|
||||
|
||||
// Set the direction property of the given unichar to the given value.
|
||||
void set_direction(UNICHAR_ID unichar_id, UNICHARSET::Direction value) {
|
||||
unichars[unichar_id].properties.direction = value;
|
||||
}
|
||||
|
||||
// Set mirror unichar id in the properties for the given unichar id.
|
||||
void set_mirror(UNICHAR_ID unichar_id, UNICHAR_ID mirror) {
|
||||
unichars[unichar_id].properties.mirror = mirror;
|
||||
}
|
||||
|
||||
// Record normalized version of unichar with the given unichar_id.
|
||||
void set_normed(UNICHAR_ID unichar_id, const char* normed) {
|
||||
unichars[unichar_id].properties.normed = normed;
|
||||
}
|
||||
|
||||
// Return the isalpha property of the given unichar.
|
||||
bool get_isalpha(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return false;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.isalpha;
|
||||
}
|
||||
|
||||
// Return the islower property of the given unichar.
|
||||
bool get_islower(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return false;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.islower;
|
||||
}
|
||||
|
||||
// Return the isupper property of the given unichar.
|
||||
bool get_isupper(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return false;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.isupper;
|
||||
}
|
||||
|
||||
// Return the isdigit property of the given unichar.
|
||||
bool get_isdigit(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return false;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.isdigit;
|
||||
}
|
||||
|
||||
// Return the ispunctuation property of the given unichar.
|
||||
bool get_ispunctuation(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return false;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.ispunctuation;
|
||||
}
|
||||
|
||||
// Return the isngram property of the given unichar.
|
||||
bool get_isngram(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return false;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.isngram;
|
||||
}
|
||||
|
||||
// Returns whether the unichar id represents a unicode value in the private
|
||||
// use area.
|
||||
bool get_isprivate(UNICHAR_ID unichar_id) const;
|
||||
|
||||
// Returns true if the ids have useful min/max top/bottom values.
|
||||
bool top_bottom_useful() const {
|
||||
return top_bottom_set_;
|
||||
}
|
||||
// Sets all ranges to empty, so they can be expanded to set the values.
|
||||
void set_ranges_empty();
|
||||
// Sets all the properties for this unicharset given a src_unicharset with
|
||||
// everything set. The unicharsets don't have to be the same, and graphemes
|
||||
// are correctly accounted for.
|
||||
void SetPropertiesFromOther(const UNICHARSET& src);
|
||||
// Expands the tops and bottoms and widths for this unicharset given a
|
||||
// src_unicharset with ranges in it. The unicharsets don't have to be the
|
||||
// same, and graphemes are correctly accounted for.
|
||||
void ExpandRangesFromOther(const UNICHARSET& src);
|
||||
// For each id in src, if it does not occur in this, add it, as in
|
||||
// SetPropertiesFromOther, otherwise expand the ranges, as in
|
||||
// ExpandRangesFromOther.
|
||||
void AppendOtherUnicharset(const UNICHARSET& src);
|
||||
// Returns the min and max bottom and top of the given unichar in
|
||||
// baseline-normalized coordinates, ie, where the baseline is
|
||||
// kBlnBaselineOffset and the meanline is kBlnBaselineOffset + kBlnXHeight
|
||||
// (See normalis.h for the definitions).
|
||||
void get_top_bottom(UNICHAR_ID unichar_id,
|
||||
int* min_bottom, int* max_bottom,
|
||||
int* min_top, int* max_top) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) {
|
||||
*min_bottom = *min_top = 0;
|
||||
*max_bottom = *max_top = 256; // kBlnCellHeight
|
||||
return;
|
||||
}
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
*min_bottom = unichars[unichar_id].properties.min_bottom;
|
||||
*max_bottom = unichars[unichar_id].properties.max_bottom;
|
||||
*min_top = unichars[unichar_id].properties.min_top;
|
||||
*max_top = unichars[unichar_id].properties.max_top;
|
||||
}
|
||||
void set_top_bottom(UNICHAR_ID unichar_id,
|
||||
int min_bottom, int max_bottom,
|
||||
int min_top, int max_top) {
|
||||
unichars[unichar_id].properties.min_bottom =
|
||||
static_cast<uinT8>(ClipToRange(min_bottom, 0, MAX_UINT8));
|
||||
unichars[unichar_id].properties.max_bottom =
|
||||
static_cast<uinT8>(ClipToRange(max_bottom, 0, MAX_UINT8));
|
||||
unichars[unichar_id].properties.min_top =
|
||||
static_cast<uinT8>(ClipToRange(min_top, 0, MAX_UINT8));
|
||||
unichars[unichar_id].properties.max_top =
|
||||
static_cast<uinT8>(ClipToRange(max_top, 0, MAX_UINT8));
|
||||
}
|
||||
// Returns the width range of the given unichar in baseline-normalized
|
||||
// coordinates, ie, where the baseline is kBlnBaselineOffset and the
|
||||
// meanline is kBlnBaselineOffset + kBlnXHeight.
|
||||
// (See normalis.h for the definitions).
|
||||
void get_width_range(UNICHAR_ID unichar_id,
|
||||
int* min_width, int* max_width) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) {
|
||||
*min_width = 0;
|
||||
*max_width = 256; // kBlnCellHeight;
|
||||
return;
|
||||
}
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
*min_width = unichars[unichar_id].properties.min_width;
|
||||
*max_width = unichars[unichar_id].properties.max_width;
|
||||
}
|
||||
void set_width_range(UNICHAR_ID unichar_id, int min_width, int max_width) {
|
||||
unichars[unichar_id].properties.min_width =
|
||||
static_cast<inT16>(ClipToRange(min_width, 0, MAX_INT16));
|
||||
unichars[unichar_id].properties.max_width =
|
||||
static_cast<inT16>(ClipToRange(max_width, 0, MAX_INT16));
|
||||
}
|
||||
// Returns the range of the x-bearing of the given unichar in
|
||||
// baseline-normalized coordinates, ie, where the baseline is
|
||||
// kBlnBaselineOffset and the meanline is kBlnBaselineOffset + kBlnXHeight.
|
||||
// (See normalis.h for the definitions).
|
||||
void get_bearing_range(UNICHAR_ID unichar_id,
|
||||
int* min_bearing, int* max_bearing) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) {
|
||||
*min_bearing = *max_bearing = 0;
|
||||
return;
|
||||
}
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
*min_bearing = unichars[unichar_id].properties.min_bearing;
|
||||
*max_bearing = unichars[unichar_id].properties.max_bearing;
|
||||
}
|
||||
void set_bearing_range(UNICHAR_ID unichar_id,
|
||||
int min_bearing, int max_bearing) {
|
||||
unichars[unichar_id].properties.min_bearing =
|
||||
static_cast<inT16>(ClipToRange(min_bearing, 0, MAX_INT16));
|
||||
unichars[unichar_id].properties.max_bearing =
|
||||
static_cast<inT16>(ClipToRange(max_bearing, 0, MAX_INT16));
|
||||
}
|
||||
// Returns the range of the x-advance of the given unichar in
|
||||
// baseline-normalized coordinates, ie, where the baseline is
|
||||
// kBlnBaselineOffset and the meanline is kBlnBaselineOffset + kBlnXHeight.
|
||||
// (See normalis.h for the definitions).
|
||||
void get_advance_range(UNICHAR_ID unichar_id,
|
||||
int* min_advance, int* max_advance) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) {
|
||||
*min_advance = *max_advance = 0;
|
||||
return;
|
||||
}
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
*min_advance = unichars[unichar_id].properties.min_advance;
|
||||
*max_advance = unichars[unichar_id].properties.max_advance;
|
||||
}
|
||||
void set_advance_range(UNICHAR_ID unichar_id,
|
||||
int min_advance, int max_advance) {
|
||||
unichars[unichar_id].properties.min_advance =
|
||||
static_cast<inT16>(ClipToRange(min_advance, 0, MAX_INT16));
|
||||
unichars[unichar_id].properties.max_advance =
|
||||
static_cast<inT16>(ClipToRange(max_advance, 0, MAX_INT16));
|
||||
}
|
||||
|
||||
// Return the script name of the given unichar.
|
||||
// The returned pointer will always be the same for the same script, it's
|
||||
// managed by unicharset and thus MUST NOT be deleted
|
||||
int get_script(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return null_sid_;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.script_id;
|
||||
}
|
||||
|
||||
// Return the character properties, eg. alpha/upper/lower/digit/punct,
|
||||
// as a bit field of unsigned int.
|
||||
unsigned int get_properties(UNICHAR_ID unichar_id) const;
|
||||
|
||||
// Return the character property as a single char. If a character has
|
||||
// multiple attributes, the main property is defined by the following order:
|
||||
// upper_case : 'A'
|
||||
// lower_case : 'a'
|
||||
// alpha : 'x'
|
||||
// digit : '0'
|
||||
// punctuation: 'p'
|
||||
char get_chartype(UNICHAR_ID unichar_id) const;
|
||||
|
||||
// Get other_case unichar id in the properties for the given unichar id.
|
||||
UNICHAR_ID get_other_case(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.other_case;
|
||||
}
|
||||
|
||||
// Returns the direction property of the given unichar.
|
||||
Direction get_direction(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return UNICHARSET::U_OTHER_NEUTRAL;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.direction;
|
||||
}
|
||||
|
||||
// Get mirror unichar id in the properties for the given unichar id.
|
||||
UNICHAR_ID get_mirror(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.mirror;
|
||||
}
|
||||
|
||||
// Returns UNICHAR_ID of the corresponding lower-case unichar.
|
||||
UNICHAR_ID to_lower(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
if (unichars[unichar_id].properties.islower) return unichar_id;
|
||||
return unichars[unichar_id].properties.other_case;
|
||||
}
|
||||
|
||||
// Returns UNICHAR_ID of the corresponding upper-case unichar.
|
||||
UNICHAR_ID to_upper(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
if (unichars[unichar_id].properties.isupper) return unichar_id;
|
||||
return unichars[unichar_id].properties.other_case;
|
||||
}
|
||||
|
||||
// Return a pointer to the CHAR_FRAGMENT class if the given
|
||||
// unichar id represents a character fragment.
|
||||
const CHAR_FRAGMENT *get_fragment(UNICHAR_ID unichar_id) const {
|
||||
if (INVALID_UNICHAR_ID == unichar_id) return NULL;
|
||||
ASSERT_HOST(contains_unichar_id(unichar_id));
|
||||
return unichars[unichar_id].properties.fragment;
|
||||
}
|
||||
|
||||
// Return the isalpha property of the given unichar representation.
|
||||
bool get_isalpha(const char* const unichar_repr) const {
|
||||
return get_isalpha(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the islower property of the given unichar representation.
|
||||
bool get_islower(const char* const unichar_repr) const {
|
||||
return get_islower(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the isupper property of the given unichar representation.
|
||||
bool get_isupper(const char* const unichar_repr) const {
|
||||
return get_isupper(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the isdigit property of the given unichar representation.
|
||||
bool get_isdigit(const char* const unichar_repr) const {
|
||||
return get_isdigit(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the ispunctuation property of the given unichar representation.
|
||||
bool get_ispunctuation(const char* const unichar_repr) const {
|
||||
return get_ispunctuation(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the character properties, eg. alpha/upper/lower/digit/punct,
|
||||
// of the given unichar representation
|
||||
unsigned int get_properties(const char* const unichar_repr) const {
|
||||
return get_properties(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
char get_chartype(const char* const unichar_repr) const {
|
||||
return get_chartype(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the script name of the given unichar representation.
|
||||
// The returned pointer will always be the same for the same script, it's
|
||||
// managed by unicharset and thus MUST NOT be deleted
|
||||
int get_script(const char* const unichar_repr) const {
|
||||
return get_script(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return a pointer to the CHAR_FRAGMENT class struct if the given
|
||||
// unichar representation represents a character fragment.
|
||||
const CHAR_FRAGMENT *get_fragment(const char* const unichar_repr) const {
|
||||
if (unichar_repr == NULL || unichar_repr[0] == '\0' ||
|
||||
!ids.contains(unichar_repr)) {
|
||||
return NULL;
|
||||
}
|
||||
return get_fragment(unichar_to_id(unichar_repr));
|
||||
}
|
||||
|
||||
// Return the isalpha property of the given unichar representation.
|
||||
// Only the first length characters from unichar_repr are used.
|
||||
bool get_isalpha(const char* const unichar_repr,
|
||||
int length) const {
|
||||
return get_isalpha(unichar_to_id(unichar_repr, length));
|
||||
}
|
||||
|
||||
// Return the islower property of the given unichar representation.
|
||||
// Only the first length characters from unichar_repr are used.
|
||||
bool get_islower(const char* const unichar_repr,
|
||||
int length) const {
|
||||
return get_islower(unichar_to_id(unichar_repr, length));
|
||||
}
|
||||
|
||||
// Return the isupper property of the given unichar representation.
|
||||
// Only the first length characters from unichar_repr are used.
|
||||
bool get_isupper(const char* const unichar_repr,
|
||||
int length) const {
|
||||
return get_isupper(unichar_to_id(unichar_repr, length));
|
||||
}
|
||||
|
||||
// Return the isdigit property of the given unichar representation.
|
||||
// Only the first length characters from unichar_repr are used.
|
||||
bool get_isdigit(const char* const unichar_repr,
|
||||
int length) const {
|
||||
return get_isdigit(unichar_to_id(unichar_repr, length));
|
||||
}
|
||||
|
||||
// Return the ispunctuation property of the given unichar representation.
|
||||
// Only the first length characters from unichar_repr are used.
|
||||
bool get_ispunctuation(const char* const unichar_repr,
|
||||
int length) const {
|
||||
return get_ispunctuation(unichar_to_id(unichar_repr, length));
|
||||
}
|
||||
|
||||
// Returns normalized version of unichar with the given unichar_id.
|
||||
const char *get_normed_unichar(UNICHAR_ID unichar_id) const {
|
||||
return unichars[unichar_id].properties.normed.string();
|
||||
}
|
||||
|
||||
// Return the script name of the given unichar representation.
|
||||
// Only the first length characters from unichar_repr are used.
|
||||
// The returned pointer will always be the same for the same script, it's
|
||||
// managed by unicharset and thus MUST NOT be deleted
|
||||
int get_script(const char* const unichar_repr,
|
||||
int length) const {
|
||||
return get_script(unichar_to_id(unichar_repr, length));
|
||||
}
|
||||
|
||||
// Return the (current) number of scripts in the script table
|
||||
int get_script_table_size() const {
|
||||
return script_table_size_used;
|
||||
}
|
||||
|
||||
// Return the script string from its id
|
||||
const char* get_script_from_script_id(int id) const {
|
||||
if (id >= script_table_size_used || id < 0)
|
||||
return null_script;
|
||||
return script_table[id];
|
||||
}
|
||||
|
||||
// Returns the id from the name of the script, or 0 if script is not found.
|
||||
// Note that this is an expensive operation since it involves iteratively
|
||||
// comparing strings in the script table. To avoid dependency on STL, we
|
||||
// won't use a hash. Instead, the calling function can use this to lookup
|
||||
// and save the ID for relevant scripts for fast comparisons later.
|
||||
int get_script_id_from_name(const char* script_name) const;
|
||||
|
||||
// Return true if the given script is the null script
|
||||
bool is_null_script(const char* script) const {
|
||||
return script == null_script;
|
||||
}
|
||||
|
||||
// Uniquify the given script. For two scripts a and b, if strcmp(a, b) == 0,
|
||||
// then the returned pointer will be the same.
|
||||
// The script parameter is copied and thus can be a temporary.
|
||||
int add_script(const char* script);
|
||||
|
||||
// Return the enabled property of the given unichar.
|
||||
bool get_enabled(UNICHAR_ID unichar_id) const {
|
||||
return unichars[unichar_id].properties.enabled;
|
||||
}
|
||||
|
||||
|
||||
int null_sid() const { return null_sid_; }
|
||||
int common_sid() const { return common_sid_; }
|
||||
int latin_sid() const { return latin_sid_; }
|
||||
int cyrillic_sid() const { return cyrillic_sid_; }
|
||||
int greek_sid() const { return greek_sid_; }
|
||||
int han_sid() const { return han_sid_; }
|
||||
int hiragana_sid() const { return hiragana_sid_; }
|
||||
int katakana_sid() const { return katakana_sid_; }
|
||||
int default_sid() const { return default_sid_; }
|
||||
|
||||
// Returns true if the unicharset has the concept of upper/lower case.
|
||||
bool script_has_upper_lower() const {
|
||||
return script_has_upper_lower_;
|
||||
}
|
||||
// Returns true if the unicharset has the concept of x-height.
|
||||
// script_has_xheight can be true even if script_has_upper_lower is not,
|
||||
// when the script has a sufficiently predominant top line with ascenders,
|
||||
// such as Devanagari and Thai.
|
||||
bool script_has_xheight() const {
|
||||
return script_has_xheight_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct UNICHAR_PROPERTIES {
|
||||
UNICHAR_PROPERTIES();
|
||||
// Initializes all properties to sensible default values.
|
||||
void Init();
|
||||
// Sets all ranges wide open. Initialization default in case there are
|
||||
// no useful values available.
|
||||
void SetRangesOpen();
|
||||
// Sets all ranges to empty. Used before expanding with font-based data.
|
||||
void SetRangesEmpty();
|
||||
// Returns true if any of the top/bottom/width/bearing/advance ranges is
|
||||
// emtpy.
|
||||
bool AnyRangeEmpty() const;
|
||||
// Expands the ranges with the ranges from the src properties.
|
||||
void ExpandRangesFrom(const UNICHAR_PROPERTIES& src);
|
||||
// Copies the properties from src into this.
|
||||
void CopyFrom(const UNICHAR_PROPERTIES& src);
|
||||
|
||||
bool isalpha;
|
||||
bool islower;
|
||||
bool isupper;
|
||||
bool isdigit;
|
||||
bool ispunctuation;
|
||||
bool isngram;
|
||||
bool enabled;
|
||||
// Possible limits of the top and bottom of the bounding box in
|
||||
// baseline-normalized coordinates, ie, where the baseline is
|
||||
// kBlnBaselineOffset and the meanline is kBlnBaselineOffset + kBlnXHeight
|
||||
// (See normalis.h for the definitions).
|
||||
uinT8 min_bottom;
|
||||
uinT8 max_bottom;
|
||||
uinT8 min_top;
|
||||
uinT8 max_top;
|
||||
// Limits on the widths of bounding box, also in baseline-normalized coords.
|
||||
inT16 min_width;
|
||||
inT16 max_width;
|
||||
// Limits on the x-bearing and advance, also in baseline-normalized coords.
|
||||
inT16 min_bearing;
|
||||
inT16 max_bearing;
|
||||
inT16 min_advance;
|
||||
inT16 max_advance;
|
||||
int script_id;
|
||||
UNICHAR_ID other_case; // id of the corresponding upper/lower case unichar
|
||||
Direction direction; // direction of this unichar
|
||||
// Mirror property is useful for reverse DAWG lookup for words in
|
||||
// right-to-left languages (e.g. "(word)" would be in
|
||||
// '[open paren]' 'w' 'o' 'r' 'd' '[close paren]' in a UTF8 string.
|
||||
// However, what we want in our DAWG is
|
||||
// '[open paren]', 'd', 'r', 'o', 'w', '[close paren]' not
|
||||
// '[close paren]', 'd', 'r', 'o', 'w', '[open paren]'.
|
||||
UNICHAR_ID mirror;
|
||||
STRING normed; // normalized version of this unichar
|
||||
// Contains meta information about the fragment if a unichar represents
|
||||
// a fragment of a character, otherwise should be set to NULL.
|
||||
// It is assumed that character fragments are added to the unicharset
|
||||
// after the corresponding 'base' characters.
|
||||
CHAR_FRAGMENT *fragment;
|
||||
};
|
||||
|
||||
struct UNICHAR_SLOT {
|
||||
char representation[UNICHAR_LEN + 1];
|
||||
UNICHAR_PROPERTIES properties;
|
||||
};
|
||||
|
||||
// Gets the properties for a grapheme string, combining properties for
|
||||
// multiple characters in a meaningful way where possible.
|
||||
// Returns false if no valid match was found in the unicharset.
|
||||
// NOTE that script_id, mirror, and other_case refer to this unicharset on
|
||||
// return and will need redirecting if the target unicharset is different.
|
||||
bool GetStrProperties(const char* utf8_str,
|
||||
UNICHAR_PROPERTIES* props) const;
|
||||
|
||||
// Load ourselves from a "file" where our only interface to the file is
|
||||
// an implementation of fgets(). This is the parsing primitive accessed by
|
||||
// the public routines load_from_file() and load_from_inmemory_file().
|
||||
bool load_via_fgets(TessResultCallback2<char *, char *, int> *fgets_cb,
|
||||
bool skip_fragments);
|
||||
|
||||
UNICHAR_SLOT* unichars;
|
||||
UNICHARMAP ids;
|
||||
int size_used;
|
||||
int size_reserved;
|
||||
char** script_table;
|
||||
int script_table_size_used;
|
||||
int script_table_size_reserved;
|
||||
const char* null_script;
|
||||
// True if the unichars have their tops/bottoms set.
|
||||
bool top_bottom_set_;
|
||||
// True if the unicharset has significant upper/lower case chars.
|
||||
bool script_has_upper_lower_;
|
||||
// True if the unicharset has a significant mean-line with significant
|
||||
// ascenders above that.
|
||||
bool script_has_xheight_;
|
||||
|
||||
// A few convenient script name-to-id mapping without using hash.
|
||||
// These are initialized when unicharset file is loaded. Anything
|
||||
// missing from this list can be looked up using get_script_id_from_name.
|
||||
int null_sid_;
|
||||
int common_sid_;
|
||||
int latin_sid_;
|
||||
int cyrillic_sid_;
|
||||
int greek_sid_;
|
||||
int han_sid_;
|
||||
int hiragana_sid_;
|
||||
int katakana_sid_;
|
||||
// The most frequently occurring script in the charset.
|
||||
int default_sid_;
|
||||
};
|
||||
|
||||
#endif // TESSERACT_CCUTIL_UNICHARSET_H__
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,46 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: ambiguous_words
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "AMBIGUOUS_WORDS" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
ambiguous_words \- generate sets of words Tesseract is likely to find ambiguous
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBambiguous_words\fR [\-l lang] \fITESSDATADIR\fR \fIWORDLIST\fR \fIAMBIGUOUSFILE\fR
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
ambiguous_words(1) runs Tesseract in a special mode, and for each word in word list, produces a set of words which Tesseract thinks might be ambiguous with it\&. \fITESSDATADIR\fR must be set to the absolute path of a directory containing \fItessdata/lang\&.traineddata\fR\&.
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1)
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) 2012 Google, Inc\&. Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,54 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: cntraining
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CNTRAINING" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
cntraining \- character normalization training for Tesseract
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBcntraining\fR [\-D \fIdir\fR] \fIFILE\fR\&...
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
cntraining takes a list of \&.tr files, from which it generates the \fBnormproto\fR data file (the character normalization sensitivity prototypes)\&.
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\-D \fIdir\fR
|
||||
.RS 4
|
||||
Directory to write output files to\&.
|
||||
.RE
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), shapeclustering(1), mftraining(1)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (c) Hewlett\-Packard Company, 1988 Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,215 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: combine_tessdata
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "COMBINE_TESSDATA" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
combine_tessdata \- combine/extract/overwrite Tesseract data
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBcombine_tessdata\fR [\fIOPTION\fR] \fIFILE\fR\&...
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
combine_tessdata(1) is the main program to combine/extract/overwrite tessdata components in [lang]\&.traineddata files\&.
|
||||
.sp
|
||||
To combine all the individual tessdata components (unicharset, DAWGs, classifier templates, ambiguities, language configs) located at, say, /home/$USER/temp/eng\&.* run:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
combine_tessdata /home/$USER/temp/eng\&.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
The result will be a combined tessdata file /home/$USER/temp/eng\&.traineddata
|
||||
.sp
|
||||
Specify option \-e if you would like to extract individual components from a combined traineddata file\&. For example, to extract language config file and the unicharset from tessdata/eng\&.traineddata run:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
combine_tessdata \-e tessdata/eng\&.traineddata \e
|
||||
/home/$USER/temp/eng\&.config /home/$USER/temp/eng\&.unicharset
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
The desired config file and unicharset will be written to /home/$USER/temp/eng\&.config /home/$USER/temp/eng\&.unicharset
|
||||
.sp
|
||||
Specify option \-o to overwrite individual components of the given [lang]\&.traineddata file\&. For example, to overwrite language config and unichar ambiguities files in tessdata/eng\&.traineddata use:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
combine_tessdata \-o tessdata/eng\&.traineddata \e
|
||||
/home/$USER/temp/eng\&.config /home/$USER/temp/eng\&.unicharambigs
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
As a result, tessdata/eng\&.traineddata will contain the new language config and unichar ambigs, plus all the original DAWGs, classifier templates, etc\&.
|
||||
.sp
|
||||
Note: the file names of the files to extract to and to overwrite from should have the appropriate file suffixes (extensions) indicating their tessdata component type (\&.unicharset for the unicharset, \&.unicharambigs for unichar ambigs, etc)\&. See k*FileSuffix variable in ccutil/tessdatamanager\&.h\&.
|
||||
.sp
|
||||
Specify option \-u to unpack all the components to the specified path:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
combine_tessdata \-u tessdata/eng\&.traineddata /home/$USER/temp/eng\&.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
This will create /home/$USER/temp/eng\&.* files with individual tessdata components from tessdata/eng\&.traineddata\&.
|
||||
.SH "OPTIONS"
|
||||
.sp
|
||||
\fB\-e\fR \fI\&.traineddata\fR \fIFILE\fR\&...: Extracts the specified components from the \&.traineddata file
|
||||
.sp
|
||||
\fB\-o\fR \fI\&.traineddata\fR \fIFILE\fR\&...: Overwrites the specified components of the \&.traineddata file with those provided on the comand line\&.
|
||||
.sp
|
||||
\fB\-u\fR \fI\&.traineddata\fR \fIPATHPREFIX\fR Unpacks the \&.traineddata using the provided prefix\&.
|
||||
.SH "CAVEATS"
|
||||
.sp
|
||||
\fIPrefix\fR refers to the full file prefix, including period (\&.)
|
||||
.SH "COMPONENTS"
|
||||
.sp
|
||||
The components in a Tesseract lang\&.traineddata file as of Tesseract 3\&.02 are briefly described below; For more information on many of these files, see \m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.PP
|
||||
lang\&.config
|
||||
.RS 4
|
||||
(Optional) Language\-specific overrides to default config variables\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.unicharset
|
||||
.RS 4
|
||||
(Required) The list of symbols that Tesseract recognizes, with properties\&. See unicharset(5)\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.unicharambigs
|
||||
.RS 4
|
||||
(Optional) This file contains information on pairs of recognized symbols which are often confused\&. For example,
|
||||
\fIrn\fR
|
||||
and
|
||||
\fIm\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.inttemp
|
||||
.RS 4
|
||||
(Required) Character shape templates for each unichar\&. Produced by mftraining(1)\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.pffmtable
|
||||
.RS 4
|
||||
(Required) The number of features expected for each unichar\&. Produced by mftraining(1) from
|
||||
\fB\&.tr\fR
|
||||
files\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.normproto
|
||||
.RS 4
|
||||
(Required) Character normalization prototypes generated by cntraining(1) from
|
||||
\fB\&.tr\fR
|
||||
files\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.punc\-dawg
|
||||
.RS 4
|
||||
(Optional) A dawg made from punctuation patterns found around words\&. The "word" part is replaced by a single space\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.word\-dawg
|
||||
.RS 4
|
||||
(Optional) A dawg made from dictionary words from the language\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.number\-dawg
|
||||
.RS 4
|
||||
(Optional) A dawg made from tokens which originally contained digits\&. Each digit is replaced by a space character\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.freq\-dawg
|
||||
.RS 4
|
||||
(Optional) A dawg made from the most frequent words which would have gone into word\-dawg\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.fixed\-length\-dawgs
|
||||
.RS 4
|
||||
(Optional) Several dawgs of different fixed lengths \(em useful for languages like Chinese\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.cube\-unicharset
|
||||
.RS 4
|
||||
(Optional) A unicharset for cube, if cube was trained on a different set of symbols\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.cube\-word\-dawg
|
||||
.RS 4
|
||||
(Optional) A word dawg for cube\(cqs alternate unicharset\&. Not needed if Cube was trained with Tesseract\(cqs unicharset\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.shapetable
|
||||
.RS 4
|
||||
(Optional) When present, a shapetable is an extra layer between the character classifier and the word recognizer that allows the character classifier to return a collection of unichar ids and fonts instead of a single unichar\-id and font\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.bigram\-dawg
|
||||
.RS 4
|
||||
(Optional) A dawg of word bigrams where the words are separated by a space and each digit is replaced by a
|
||||
\fI?\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.unambig\-dawg
|
||||
.RS 4
|
||||
(Optional) TODO: Describe\&.
|
||||
.RE
|
||||
.PP
|
||||
lang\&.params\-training\-model
|
||||
.RS 4
|
||||
(Optional) TODO: Describe\&.
|
||||
.RE
|
||||
.SH "HISTORY"
|
||||
.sp
|
||||
combine_tessdata(1) first appeared in version 3\&.00 of Tesseract
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), wordlist2dawg(1), cntraining(1), mftraining(1), unicharset(5), unicharambigs(5)
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) 2009, Google Inc\&. Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,55 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: dawg2wordlist
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "DAWG2WORDLIST" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
dawg2wordlist \- convert a Tesseract DAWG to a wordlist
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBdawg2wordlist\fR \fIUNICHARSET\fR \fIDAWG\fR \fIWORDLIST\fR
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
dawg2wordlist(1) converts a Tesseract Directed Acyclic Word Graph (DAWG) to a list of words using a unicharset as key\&.
|
||||
.SH "OPTIONS"
|
||||
.sp
|
||||
\fIUNICHARSET\fR The unicharset of the language\&. This is the unicharset generated by mftraining(1)\&.
|
||||
.sp
|
||||
\fIDAWG\fR The input DAWG, created by wordlist2dawg(1)
|
||||
.sp
|
||||
\fIWORDLIST\fR Plain text (output) file in UTF\-8, one word per line
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), mftraining(1), wordlist2dawg(1), unicharset(5), combine_tessdata(1)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) 2012 Google, Inc\&. Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,94 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: mftraining
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "MFTRAINING" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
mftraining \- feature training for Tesseract
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
mftraining \-U \fIunicharset\fR \-O \fIlang\&.unicharset\fR \fIFILE\fR\&...
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
mftraining takes a list of \&.tr files, from which it generates the files \fBinttemp\fR (the shape prototypes), \fBshapetable\fR, and \fBpffmtable\fR (the number of expected features for each character)\&. (A fourth file called Microfeat is also written by this program, but it is not used\&.)
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\-U \fIFILE\fR
|
||||
.RS 4
|
||||
(Input) The unicharset generated by unicharset_extractor(1)
|
||||
.RE
|
||||
.PP
|
||||
\-F \fIfont_properties_file\fR
|
||||
.RS 4
|
||||
(Input) font properties file, each line is of the following form, where each field other than the font name is 0 or 1:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
*font_name* *italic* *bold* *fixed_pitch* *serif* *fraktur*
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.RE
|
||||
.PP
|
||||
\-X \fIxheights_file\fR
|
||||
.RS 4
|
||||
(Input) x heights file, each line is of the following form, where xheight is calculated as the pixel x height of a character drawn at 32pt on 300 dpi\&. [ That is, if base x height + ascenders + descenders = 133, how much is x height? ]
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
*font_name* *xheight*
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.RE
|
||||
.PP
|
||||
\-D \fIdir\fR
|
||||
.RS 4
|
||||
Directory to write output files to\&.
|
||||
.RE
|
||||
.PP
|
||||
\-O \fIFILE\fR
|
||||
.RS 4
|
||||
(Output) The output unicharset that will be given to combine_tessdata(1)
|
||||
.RE
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), cntraining(1), unicharset_extractor(1), combine_tessdata(1), shapeclustering(1), unicharset(5)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) Hewlett\-Packard Company, 1988 Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,94 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: shapeclustering
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "SHAPECLUSTERING" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
shapeclustering \- shape clustering training for Tesseract
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
shapeclustering \-D \fIoutput_dir\fR \-U \fIunicharset\fR \-O \fImfunicharset\fR \-F \fIfont_props\fR \-X \fIxheights\fR \fIFILE\fR\&...
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
shapeclustering(1) takes extracted feature \&.tr files (generated by tesseract(1) run in a special mode from box files) and produces a file \fBshapetable\fR and an enhanced unicharset\&. This program is still experimental, and is not required (yet) for training Tesseract\&.
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\-U \fIFILE\fR
|
||||
.RS 4
|
||||
The unicharset generated by unicharset_extractor(1)\&.
|
||||
.RE
|
||||
.PP
|
||||
\-D \fIdir\fR
|
||||
.RS 4
|
||||
Directory to write output files to\&.
|
||||
.RE
|
||||
.PP
|
||||
\-F \fIfont_properties_file\fR
|
||||
.RS 4
|
||||
(Input) font properties file, where each line is of the following form, where each field other than the font name is 0 or 1:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
\*(Aqfont_name\*(Aq \*(Aqitalic\*(Aq \*(Aqbold\*(Aq \*(Aqfixed_pitch\*(Aq \*(Aqserif\*(Aq \*(Aqfraktur\*(Aq
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.RE
|
||||
.PP
|
||||
\-X \fIxheights_file\fR
|
||||
.RS 4
|
||||
(Input) x heights file, each line is of the following form, where xheight is calculated as the pixel x height of a character drawn at 32pt on 300 dpi\&. [ That is, if base x height + ascenders + descenders = 133, how much is x height? ]
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
\*(Aqfont_name\*(Aq \*(Aqxheight\*(Aq
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.RE
|
||||
.PP
|
||||
\-O \fIFILE\fR
|
||||
.RS 4
|
||||
The output unicharset that will be given to combine_tessdata(1)\&.
|
||||
.RE
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), cntraining(1), unicharset_extractor(1), combine_tessdata(1), unicharset(5)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) Google, 2011 Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,194 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: tesseract
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 04/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "TESSERACT" "1" "04/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
tesseract \- command\-line OCR engine
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBtesseract\fR \fIimagename\fR \fIoutbase\fR [\fI\-l lang\fR] [\fI\-psm N\fR] [\fIconfigfile\fR \&...]
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
tesseract(1) is a commercial quality OCR engine originally developed at HP between 1985 and 1995\&. In 1995, this engine was among the top 3 evaluated by UNLV\&. It was open\-sourced by HP and UNLV in 2005, and has been developed at Google since then\&.
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\fIimagename\fR
|
||||
.RS 4
|
||||
The name of the input image\&. Most image file formats (anything readable by Leptonica) are supported\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIoutbase\fR
|
||||
.RS 4
|
||||
The basename of the output file (to which the appropriate extension will be appended)\&. By default the output will be named
|
||||
\fIoutbase\&.txt\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
\fI\-l lang\fR
|
||||
.RS 4
|
||||
The language to use\&. If none is specified, English is assumed\&. Multiple languages may be specified, separated by plus characters\&. Tesseract uses 3\-character ISO 639\-2 language codes\&. (See LANGUAGES)
|
||||
.RE
|
||||
.PP
|
||||
\fI\-psm N\fR
|
||||
.RS 4
|
||||
Set Tesseract to only run a subset of layout analysis and assume a certain form of image\&. The options for
|
||||
\fBN\fR
|
||||
are:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
0 = Orientation and script detection (OSD) only\&.
|
||||
1 = Automatic page segmentation with OSD\&.
|
||||
2 = Automatic page segmentation, but no OSD, or OCR\&.
|
||||
3 = Fully automatic page segmentation, but no OSD\&. (Default)
|
||||
4 = Assume a single column of text of variable sizes\&.
|
||||
5 = Assume a single uniform block of vertically aligned text\&.
|
||||
6 = Assume a single uniform block of text\&.
|
||||
7 = Treat the image as a single text line\&.
|
||||
8 = Treat the image as a single word\&.
|
||||
9 = Treat the image as a single word in a circle\&.
|
||||
10 = Treat the image as a single character\&.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.RE
|
||||
.PP
|
||||
\fI\-v\fR
|
||||
.RS 4
|
||||
Returns the current version of the tesseract(1) executable\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIconfigfile\fR
|
||||
.RS 4
|
||||
The name of a config to use\&. A config is a plaintext file which contains a list of variables and their values, one per line, with a space separating variable from value\&. Interesting config files include:
|
||||
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
hocr \- Output in hOCR format instead of as a text file\&.
|
||||
.RE
|
||||
.RE
|
||||
.sp
|
||||
\fBNota Bene:\fR The options \fI\-l lang\fR and \fI\-psm N\fR must occur before any \fIconfigfile\fR\&.
|
||||
.SH "LANGUAGES"
|
||||
.sp
|
||||
There are currently language packs available for the following languages:
|
||||
.sp
|
||||
\fBara\fR (Arabic), \fBaze\fR (Azerbauijani), \fBbul\fR (Bulgarian), \fBcat\fR (Catalan), \fBces\fR (Czech), \fBchi_sim\fR (Simplified Chinese), \fBchi_tra\fR (Traditional Chinese), \fBchr\fR (Cherokee), \fBdan\fR (Danish), \fBdan\-frak\fR (Danish (Fraktur)), \fBdeu\fR (German), \fBell\fR (Greek), \fBeng\fR (English), \fBenm\fR (Old English), \fBepo\fR (Esperanto), \fBest\fR (Estonian), \fBfin\fR (Finnish), \fBfra\fR (French), \fBfrm\fR (Old French), \fBglg\fR (Galician), \fBheb\fR (Hebrew), \fBhin\fR (Hindi), \fBhrv\fR (Croation), \fBhun\fR (Hungarian), \fBind\fR (Indonesian), \fBita\fR (Italian), \fBjpn\fR (Japanese), \fBkor\fR (Korean), \fBlav\fR (Latvian), \fBlit\fR (Lithuanian), \fBnld\fR (Dutch), \fBnor\fR (Norwegian), \fBpol\fR (Polish), \fBpor\fR (Portuguese), \fBron\fR (Romanian), \fBrus\fR (Russian), \fBslk\fR (Slovakian), \fBslv\fR (Slovenian), \fBsqi\fR (Albanian), \fBspa\fR (Spanish), \fBsrp\fR (Serbian), \fBswe\fR (Swedish), \fBtam\fR (Tamil), \fBtel\fR (Telugu), \fBtgl\fR (Tagalog), \fBtha\fR (Thai), \fBtur\fR (Turkish), \fBukr\fR (Ukrainian), \fBvie\fR (Vietnamese)
|
||||
.sp
|
||||
To use a non\-standard language pack named \fBfoo\&.traineddata\fR, set the \fBTESSDATA_PREFIX\fR environment variable so the file can be found at \fBTESSDATA_PREFIX\fR/tessdata/\fBfoo\fR\&.traineddata and give Tesseract the argument \fI\-l foo\fR\&.
|
||||
.SH "CONFIG FILES AND AUGMENTING WITH USER DATA"
|
||||
.sp
|
||||
Tesseract config files consist of lines with variable\-value pairs (space separated)\&. The variables are documented as flags in the source code like the following one in tesseractclass\&.h:
|
||||
.sp
|
||||
STRING_VAR_H(tessedit_char_blacklist, "", "Blacklist of chars not to recognize");
|
||||
.sp
|
||||
These variables may enable or disable various features of the engine, and may cause it to load (or not load) various data\&. For instance, let\(cqs suppose you want to OCR in English, but suppress the normal dictionary and load an alternative word list and an alternative list of patterns \(em these two files are the most commonly used extra data files\&.
|
||||
.sp
|
||||
If your language pack is in /path/to/eng\&.traineddata and the hocr config is in /path/to/configs/hocr then create three new files:
|
||||
.sp
|
||||
/path/to/eng\&.user\-words:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
the
|
||||
quick
|
||||
brown
|
||||
fox
|
||||
jumped
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
/path/to/eng\&.user\-patterns:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
1\-\ed\ed\ed\-GOOG\-411
|
||||
www\&.\en\e\e\e*\&.com
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
/path/to/configs/bazaar:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
load_system_dawg F
|
||||
load_freq_dawg F
|
||||
user_words_suffix user\-words
|
||||
user_patterns_suffix user\-patterns
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
Now, if you pass the word \fIbazaar\fR as a trailing command line parameter to Tesseract, Tesseract will not bother loading the system dictionary nor the dictionary of frequent words and will load and use the eng\&.user\-words and eng\&.user\-patterns files you provided\&. The former is a simple word list, one per line\&. The format of the latter is documented in dict/trie\&.h on read_pattern_list()\&.
|
||||
.SH "HISTORY"
|
||||
.sp
|
||||
The engine was developed at Hewlett Packard Laboratories Bristol and at Hewlett Packard Co, Greeley Colorado between 1985 and 1994, with some more changes made in 1996 to port to Windows, and some C++izing in 1998\&. A lot of the code was written in C, and then some more was written in C++\&. The C\e++ code makes heavy use of a list system using macros\&. This predates stl, was portable before stl, and is more efficient than stl lists, but has the big negative that if you do get a segmentation violation, it is hard to debug\&.
|
||||
.sp
|
||||
Version 2\&.00 brought Unicode (UTF\-8) support, six languages, and the ability to train Tesseract\&.
|
||||
.sp
|
||||
Tesseract was included in UNLV\(cqs Fourth Annual Test of OCR Accuracy\&. See \m[blue]\fBhttp://www\&.isri\&.unlv\&.edu/downloads/AT\-1995\&.pdf\fR\m[]\&. With Tesseract 2\&.00, scripts are now included to allow anyone to reproduce some of these tests\&. See \m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TestingTesseract\fR\m[] for more details\&.
|
||||
.sp
|
||||
Tesseract 3\&.00 adds a number of new languages, including Chinese, Japanese, and Korean\&. It also introduces a new, single\-file based system of managing language data\&.
|
||||
.sp
|
||||
Tesseract 3\&.02 adds BiDirectional text support, the ability to recognize multiple languages in a single image, and improved layout analysis\&.
|
||||
.sp
|
||||
For further details, see the file ReleaseNotes included with the distribution\&.
|
||||
.SH "RESOURCES"
|
||||
.sp
|
||||
Main web site: \m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/\fR\m[] Information on training: \m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
ambiguous_words(1), cntraining(1), combine_tessdata(1), dawg2wordlist(1), shape_training(1), mftraining(1), unicharambigs(5), unicharset(5), unicharset_extractor(1), wordlist2dawg(1)
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
Tesseract development was led at Hewlett\-Packard and Google by Ray Smith\&. The development team has included:
|
||||
.sp
|
||||
Ahmad Abdulkader, Chris Newton, Dan Johnson, Dar\-Shyang Lee, David Eger, Eric Wiseblatt, Faisal Shafait, Hiroshi Takenaka, Joe Liu, Joern Wanke, Mark Seaman, Mickey Namiki, Nicholas Beato, Oded Fuhrmann, Phil Cheatle, Pingping Xiu, Pong Eksombatchai (Chantat), Ranjith Unnikrishnan, Raquel Romano, Ray Smith, Rika Antonova, Robert Moss, Samuel Charron, Sheelagh Lloyd, Shobhit Saxena, and Thomas Kielbus\&.
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Licensed under the Apache License, Version 2\&.0
|
||||
@@ -1,69 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: unicharset_extractor
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "UNICHARSET_EXTRACTOR" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
unicharset_extractor \- extract unicharset from Tesseract boxfiles
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBunicharset_extractor\fR \fI[\-D dir]\fR \fIFILE\fR\&...
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
Tesseract needs to know the set of possible characters it can output\&. To generate the unicharset data file, use the unicharset_extractor program on the same training pages bounding box files as used for clustering:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
unicharset_extractor fontfile_1\&.box fontfile_2\&.box \&.\&.\&.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
The unicharset will be put into the file \fIdir/unicharset\fR, or simply \fI\&./unicharset\fR if no output directory is provided\&.
|
||||
.sp
|
||||
Tesseract also needs to have access to character properties isalpha, isdigit, isupper, islower, ispunctuation\&. all of this auxilury data and more is encoded in this file\&. (See unicharset(5))
|
||||
.sp
|
||||
If your system supports the wctype functions, these values will be set automatically by unicharset_extractor and there is no need to edit the unicharset file\&. On some older systems (eg Windows 95), the unicharset file must be edited by hand to add these property description codes\&.
|
||||
.sp
|
||||
\fBNOTE\fR The unicharset file must be regenerated whenever inttemp, normproto and pffmtable are generated (i\&.e\&. they must all be recreated when the box file is changed) as they have to be in sync\&. This is made easier than in previous versions by running unicharset_extractor before mftraining and cntraining, and giving the unicharset to mftraining\&.
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), unicharset(5)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "HISTORY"
|
||||
.sp
|
||||
unicharset_extractor first appeared in Tesseract 2\&.00\&.
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) 2006, Google Inc\&. Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,72 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: wordlist2dawg
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "WORDLIST2DAWG" "1" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
wordlist2dawg \- convert a wordlist to a DAWG for Tesseract
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBwordlist2dawg\fR \fIWORDLIST\fR \fIDAWG\fR \fIlang\&.unicharset\fR
|
||||
.sp
|
||||
\fBwordlist2dawg\fR \-t \fIWORDLIST\fR \fIDAWG\fR \fIlang\&.unicharset\fR
|
||||
.sp
|
||||
\fBwordlist2dawg\fR \-r 1 \fIWORDLIST\fR \fIDAWG\fR \fIlang\&.unicharset\fR
|
||||
.sp
|
||||
\fBwordlist2dawg\fR \-r 2 \fIWORDLIST\fR \fIDAWG\fR \fIlang\&.unicharset\fR
|
||||
.sp
|
||||
\fBwordlist2dawg\fR \-l <short> <long> \fIWORDLIST\fR \fIDAWG\fR \fIlang\&.unicharset\fR
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
wordlist2dawg(1) converts a wordlist to a Directed Acyclic Word Graph (DAWG) for use with Tesseract\&. A DAWG is a compressed, space and time efficient representation of a word list\&.
|
||||
.SH "OPTIONS"
|
||||
.sp
|
||||
\-t Verify that a given dawg file is equivalent to a given wordlist\&.
|
||||
.sp
|
||||
\-r 1 Reverse a word if it contains an RTL character\&.
|
||||
.sp
|
||||
\-r 2 Reverse all words\&.
|
||||
.sp
|
||||
\-l <short> <long> Produce a file with several dawgs in it, one each for words of length <short>, <short+1>,\&... <long>
|
||||
.SH "ARGUMENTS"
|
||||
.sp
|
||||
\fIWORDLIST\fR A plain text file in UTF\-8, one word per line\&.
|
||||
.sp
|
||||
\fIDAWG\fR The output DAWG to write\&.
|
||||
.sp
|
||||
\fIlang\&.unicharset\fR The unicharset of the language\&. This is the unicharset generated by mftraining(1)\&.
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), combine_tessdata(1), dawg2wordlist(1)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) 2006 Google, Inc\&. Licensed under the Apache License, Version 2\&.0
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,120 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: unicharambigs
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "UNICHARAMBIGS" "5" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
unicharambigs \- Tesseract unicharset ambiguities
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
The unicharambigs file (a component of traineddata, see combine_tessdata(1) ) is used by Tesseract to represent possible ambiguities between characters, or groups of characters\&.
|
||||
.sp
|
||||
The file contains a number of lines, laid out as follow:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
[num] <TAB> [char(s)] <TAB> [num] <TAB> [char(s)] <TAB> [num]
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
.TS
|
||||
tab(:);
|
||||
lt lt
|
||||
lt lt
|
||||
lt lt
|
||||
lt lt
|
||||
lt lt.
|
||||
T{
|
||||
.sp
|
||||
Field one
|
||||
T}:T{
|
||||
.sp
|
||||
the number of characters contained in field two
|
||||
T}
|
||||
T{
|
||||
.sp
|
||||
Field two
|
||||
T}:T{
|
||||
.sp
|
||||
the character sequence to be replaced
|
||||
T}
|
||||
T{
|
||||
.sp
|
||||
Field three
|
||||
T}:T{
|
||||
.sp
|
||||
the number of characters contained in field four
|
||||
T}
|
||||
T{
|
||||
.sp
|
||||
Field four
|
||||
T}:T{
|
||||
.sp
|
||||
the character sequence used to replace field two
|
||||
T}
|
||||
T{
|
||||
.sp
|
||||
Field five
|
||||
T}:T{
|
||||
.sp
|
||||
contains either 1 or 0\&. 1 denotes a mandatory replacement, 0 denotes an optional replacement\&.
|
||||
T}
|
||||
.TE
|
||||
.sp 1
|
||||
.sp
|
||||
Characters appearing in fields two and four should appear in unicharset\&. The numbers in fields one and three refer to the number of unichars (not bytes)\&.
|
||||
.SH "EXAMPLE"
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
2 \*(Aq \*(Aq 1 " 1
|
||||
1 m 2 r n 0
|
||||
3 i i i 1 m 0
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
In this example, all instances of the \fI2\fR character sequence \fI\*(Aq\fR\*(Aq will \fBalways\fR be replaced by the \fI1\fR character sequence \fI"\fR; a \fI1\fR character sequence \fIm\fR \fBmay\fR be replaced by the \fI2\fR character sequence \fIrn\fR, and the \fI3\fR character sequence \fBmay\fR be replaced by the \fI1\fR character sequence \fIm\fR\&.
|
||||
.SH "HISTORY"
|
||||
.sp
|
||||
The unicharambigs file first appeared in Tesseract 3\&.00; prior to that, a similar format, called DangAmbigs (\fIdangerous ambiguities\fR) was used: the format was almost identical, except only mandatory replacements could be specified, and field 5 was absent\&.
|
||||
.SH "BUGS"
|
||||
.sp
|
||||
This is a documentation "bug": it\(cqs not currently clear what should be done in the case of ligatures (such as \fIfi\fR) which may also appear as regular letters in the unicharset\&.
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), unicharset(5)
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,220 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: unicharset
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
||||
.\" Date: 02/09/2012
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "UNICHARSET" "5" "02/09/2012" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
unicharset \- character properties file used by tesseract(1)
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
Tesseract\(cqs unicharset file contains information on each symbol (unichar) the Tesseract OCR engine is trained to recognize\&.
|
||||
.sp
|
||||
A unicharset file (i\&.e\&. \fIeng\&.unicharset\fR) is distributed as part of a Tesseract language pack (i\&.e\&. \fIeng\&.traineddata\fR)\&. For information on extracting the unicharset file, see combine_tessdata(1)\&.
|
||||
.sp
|
||||
The first line of a unicharset file contains the number of unichars in the file\&. After this line, each subsequent line provides information for a single unichar\&. The first such line contains a placeholder reserved for the space character\&. Each unichar is referred to within Tesseract by its Unichar ID, which is the line number (minus 1) within the unicharset file\&. Therefore, space gets unichar 0\&.
|
||||
.sp
|
||||
Each unichar line in the unicharset file (v2+) may have four space\-separated fields:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
\*(Aqcharacter\*(Aq \*(Aqproperties\*(Aq \*(Aqscript\*(Aq \*(Aqid\*(Aq
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
Starting with Tesseract v3\&.02, more information may be given for each unichar:
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
\*(Aqcharacter\*(Aq \*(Aqproperties\*(Aq \*(Aqglyph_metrics\*(Aq \*(Aqscript\*(Aq \*(Aqother_case\*(Aq \*(Aqdirection\*(Aq \*(Aqmirror\*(Aq \*(Aqnormed_form\*(Aq
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
Entries:
|
||||
.PP
|
||||
\fIcharacter\fR
|
||||
.RS 4
|
||||
The UTF\-8 encoded string to be produced for this unichar\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIproperties\fR
|
||||
.RS 4
|
||||
An integer mask of character properties, one per bit\&. From least to most significant bit, these are: isalpha, islower, isupper, isdigit, ispunctuation\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIglyph_metrics\fR
|
||||
.RS 4
|
||||
Ten comma\-separated integers representing various standards for where this glyph is to be found within a baseline\-normalized coordinate system where 128 is normalized to x\-height\&.
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
min_bottom, max_bottom: the ranges where the bottom of the character can be found\&.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
min_top, max_top: the ranges where the top of the character may be found\&.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
min_width, max_width: horizontal width of the character\&.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
min_bearing, max_bearing: how far from the usual start position does the leftmost part of the character begin\&.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
min_advance, max_advance: how far from the printer\(cqs cell left do we advance to begin the next character\&.
|
||||
.RE
|
||||
.RE
|
||||
.PP
|
||||
\fIscript\fR
|
||||
.RS 4
|
||||
Name of the script (Latin, Common, Greek, Cyrillic, Han, null)\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIother_case\fR
|
||||
.RS 4
|
||||
The Unichar ID of the other case version of this character (upper or lower)\&.
|
||||
.RE
|
||||
.PP
|
||||
\fIdirection\fR
|
||||
.RS 4
|
||||
The Unicode BiDi direction of this character, as defined by ICU\(cqs enum UCharDirection\&. (0 = Left to Right, 1 = Right to Left, 2 = European Number\&...)
|
||||
.RE
|
||||
.PP
|
||||
\fImirror\fR
|
||||
.RS 4
|
||||
The Unichar ID of the BiDirectional mirror of this character\&. For example the mirror of open paren is close paren, but Latin Capital C has no mirror, so it remains a Latin Capital C\&.
|
||||
.RE
|
||||
.PP
|
||||
\fInormed_form\fR
|
||||
.RS 4
|
||||
The UTF\-8 representation of a "normalized form" of this unichar for the purpose of blaming a module for errors given ground truth text\&. For instance, a left or right single quote may normalize to an ASCII quote\&.
|
||||
.RE
|
||||
.SH "EXAMPLE (V2)"
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
; 10 Common 46
|
||||
b 3 Latin 59
|
||||
W 5 Latin 40
|
||||
7 8 Common 66
|
||||
= 0 Common 93
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.sp
|
||||
";" is a punctuation character\&. Its properties are thus represented by the binary number 10000 (10 in hexadecimal)\&.
|
||||
.sp
|
||||
"b" is an alphabetic character and a lower case character\&. Its properties are thus represented by the binary number 00011 (3 in hexadecimal)\&.
|
||||
.sp
|
||||
"W" is an alphabetic character and an upper case character\&. Its properties are thus represented by the binary number 00101 (5 in hexadecimal)\&.
|
||||
.sp
|
||||
"7" is just a digit\&. Its properties are thus represented by the binary number 01000 (8 in hexadecimal)\&.
|
||||
.sp
|
||||
"=" is not punctuation nor a digit nor an alphabetic character\&. Its properties are thus represented by the binary number 00000 (0 in hexadecimal)\&.
|
||||
.sp
|
||||
Japanese or Chinese alphabetic character properties are represented by the binary number 00001 (1 in hexadecimal): they are alphabetic, but neither upper nor lower case\&.
|
||||
.SH "EXAMPLE (V3.02)"
|
||||
.sp
|
||||
.if n \{\
|
||||
.RS 4
|
||||
.\}
|
||||
.nf
|
||||
110
|
||||
NULL 0 NULL 0
|
||||
N 5 59,68,216,255,87,236,0,27,104,227 Latin 11 0 1 N
|
||||
Y 5 59,68,216,255,91,205,0,47,91,223 Latin 33 0 2 Y
|
||||
1 8 59,69,203,255,45,128,0,66,74,173 Common 3 2 3 1
|
||||
9 8 18,66,203,255,89,156,0,39,104,173 Common 4 2 4 9
|
||||
a 3 58,65,186,198,85,164,0,26,97,185 Latin 56 0 5 a
|
||||
\&. \&. \&.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
.\}
|
||||
.SH "CAVEATS"
|
||||
.sp
|
||||
Although the unicharset reader maintains the ability to read unicharsets of older formats and will assign default values to missing fields, the accuracy will be degraded\&.
|
||||
.sp
|
||||
Further, most other data files are indexed by the unicharset file, so changing it without re\-generating the others is likely to have dire consequences\&.
|
||||
.SH "HISTORY"
|
||||
.sp
|
||||
The unicharset format first appeared with Tesseract 2\&.00, which was the first version to support languages other than English\&. The unicharset file contained only the first two fields, and the "ispunctuation" property was absent (punctuation was regarded as "0", as "=" is in the above example\&.
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
tesseract(1), combine_tessdata(1), unicharset_extractor(1)
|
||||
.sp
|
||||
\m[blue]\fBhttp://code\&.google\&.com/p/tesseract\-ocr/wiki/TrainingTesseract3\fR\m[]
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985\-1995) and Google (2006\-present)\&.
|
||||
@@ -1,7 +0,0 @@
|
||||
tessedit_ambigs_training 1
|
||||
load_freq_dawg 0
|
||||
load_punc_dawg 0
|
||||
load_system_dawg 0
|
||||
load_number_dawg 0
|
||||
ambigs_debug_level 3
|
||||
load_fixed_length_dawgs 0
|
||||
@@ -1 +0,0 @@
|
||||
tessedit_zero_rejection T
|
||||
@@ -1,14 +0,0 @@
|
||||
disable_character_fragments T
|
||||
file_type .bl
|
||||
textord_fast_pitch_test T
|
||||
tessedit_single_match 0
|
||||
tessedit_zero_rejection T
|
||||
tessedit_minimal_rejection F
|
||||
tessedit_write_rep_codes F
|
||||
il1_adaption_test 1
|
||||
edges_children_fix F
|
||||
edges_childarea 0.65
|
||||
edges_boxarea 0.9
|
||||
tessedit_resegment_from_boxes T
|
||||
tessedit_train_from_boxes T
|
||||
textord_no_rejects T
|
||||
@@ -1,15 +0,0 @@
|
||||
file_type .bl
|
||||
#tessedit_use_nn F
|
||||
textord_fast_pitch_test T
|
||||
tessedit_single_match 0
|
||||
tessedit_zero_rejection T
|
||||
tessedit_minimal_rejection F
|
||||
tessedit_write_rep_codes F
|
||||
il1_adaption_test 1
|
||||
edges_children_fix F
|
||||
edges_childarea 0.65
|
||||
edges_boxarea 0.9
|
||||
tessedit_resegment_from_boxes T
|
||||
tessedit_train_from_boxes T
|
||||
#textord_repeat_extraction F
|
||||
textord_no_rejects T
|
||||
@@ -1 +0,0 @@
|
||||
tessedit_char_whitelist 0123456789-.
|
||||
@@ -1 +0,0 @@
|
||||
tessedit_create_hocr 1
|
||||
@@ -1,2 +0,0 @@
|
||||
interactive_display_mode T
|
||||
tessedit_display_outwords T
|
||||
@@ -1,4 +0,0 @@
|
||||
textord_skewsmooth_offset 8
|
||||
textord_skewsmooth_offset2 8
|
||||
textord_merge_desc 0.5
|
||||
textord_no_rejects 1
|
||||
@@ -1,2 +0,0 @@
|
||||
tessedit_resegment_from_line_boxes 1
|
||||
tessedit_make_boxes_from_boxes 1
|
||||
@@ -1 +0,0 @@
|
||||
debug_file tesseract.log
|
||||
@@ -1 +0,0 @@
|
||||
tessedit_create_boxfile 1
|
||||
@@ -1 +0,0 @@
|
||||
debug_file /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
tessedit_resegment_from_boxes 1
|
||||
tessedit_make_boxes_from_boxes 1
|
||||
@@ -1,12 +0,0 @@
|
||||
textord_show_blobs 0
|
||||
textord_debug_tabfind 3
|
||||
textord_tabfind_show_partitions 1
|
||||
textord_tabfind_show_initial_partitions 1
|
||||
textord_tabfind_show_columns 1
|
||||
textord_tabfind_show_blocks 1
|
||||
textord_tabfind_show_initialtabs 1
|
||||
textord_tabfind_show_finaltabs 1
|
||||
textord_tabfind_show_strokewidths 1
|
||||
textord_tabfind_show_vlines 0
|
||||
textord_tabfind_show_images 1
|
||||
tessedit_dump_pageseg_images 0
|
||||
@@ -1,2 +0,0 @@
|
||||
tessedit_write_unlv 1
|
||||
tessedit_pageseg_mode 6
|
||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
# No content needed as all defaults are correct.
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
chop_enable 0
|
||||
wordrec_enable_assoc 0
|
||||
@@ -1,7 +0,0 @@
|
||||
#################################################
|
||||
# Adaptive Matcher Using PreAdapted Templates
|
||||
#################################################
|
||||
|
||||
classify_enable_adaptive_debugger 1
|
||||
matcher_debug_flags 6
|
||||
matcher_debug_level 1
|
||||
@@ -1,13 +0,0 @@
|
||||
#################################################
|
||||
# Adaptive Matcher Using PreAdapted Templates
|
||||
#################################################
|
||||
|
||||
classify_enable_adaptive_debugger 1
|
||||
matcher_debug_flags 6
|
||||
matcher_debug_level 1
|
||||
|
||||
wordrec_display_splits 0
|
||||
wordrec_display_all_words 1
|
||||
wordrec_display_all_blobs 1
|
||||
wordrec_display_segmentations 2
|
||||
classify_debug_level 1
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#################################################
|
||||
# Adaptive Matcher Using PreAdapted Templates
|
||||
#################################################
|
||||
|
||||
wordrec_display_splits 0
|
||||
wordrec_display_all_words 1
|
||||
wordrec_display_all_blobs 1
|
||||
wordrec_display_segmentations 2
|
||||
classify_debug_level 1
|
||||
stopper_debug_level 1
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_fft
|
||||
* FFT functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_fft FFT functions
|
||||
* @ingroup lavc_misc
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
typedef struct FFTComplex {
|
||||
FFTSample re, im;
|
||||
} FFTComplex;
|
||||
|
||||
typedef struct FFTContext FFTContext;
|
||||
|
||||
/**
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
*/
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
*/
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
*/
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
|
||||
enum RDFTransformType {
|
||||
DFT_R2C,
|
||||
IDFT_C2R,
|
||||
IDFT_R2C,
|
||||
DFT_C2R,
|
||||
};
|
||||
|
||||
typedef struct RDFTContext RDFTContext;
|
||||
|
||||
/**
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*/
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
|
||||
typedef struct DCTContext DCTContext;
|
||||
|
||||
enum DCTTransformType {
|
||||
DCT_II = 0,
|
||||
DCT_III,
|
||||
DCT_I,
|
||||
DST_I,
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up DCT.
|
||||
* @param nbits size of the input array:
|
||||
* (1 << nbits) for DCT-II, DCT-III and DST-I
|
||||
* (1 << nbits) + 1 for DCT-I
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*/
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_AVFFT_H */
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* DXVA2 HW acceleration
|
||||
*
|
||||
* copyright (c) 2009 Laurent Aimar
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DXVA_H
|
||||
#define AVCODEC_DXVA_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_dxva2
|
||||
* Public libavcodec DXVA2 header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_dxva2 DXVA2
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the DXVA2 FFmpeg HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct dxva_context {
|
||||
/**
|
||||
* DXVA2 decoder object
|
||||
*/
|
||||
IDirectXVideoDecoder *decoder;
|
||||
|
||||
/**
|
||||
* DXVA2 configuration used to create the decoder
|
||||
*/
|
||||
const DXVA2_ConfigPictureDecode *cfg;
|
||||
|
||||
/**
|
||||
* The number of surface in the surface array
|
||||
*/
|
||||
unsigned surface_count;
|
||||
|
||||
/**
|
||||
* The array of Direct3D surfaces used to create the decoder
|
||||
*/
|
||||
LPDIRECT3DSURFACE9 *surface;
|
||||
|
||||
/**
|
||||
* A bit field configuring the workarounds needed for using the decoder
|
||||
*/
|
||||
uint64_t workaround;
|
||||
|
||||
/**
|
||||
* Private to the FFmpeg AVHWAccel implementation
|
||||
*/
|
||||
unsigned report_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_DXVA_H */
|
||||
@@ -1,398 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_OLD_CODEC_IDS_H
|
||||
#define AVCODEC_OLD_CODEC_IDS_H
|
||||
|
||||
#include "libavutil/common.h"
|
||||
|
||||
/*
|
||||
* This header exists to prevent new codec IDs from being accidentally added to
|
||||
* the deprecated list.
|
||||
* Do not include it directly. It will be removed on next major bump
|
||||
*
|
||||
* Do not add new items to this list. Use the AVCodecID enum instead.
|
||||
*/
|
||||
|
||||
CODEC_ID_NONE = AV_CODEC_ID_NONE,
|
||||
|
||||
/* video codecs */
|
||||
CODEC_ID_MPEG1VIDEO,
|
||||
CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
|
||||
CODEC_ID_MPEG2VIDEO_XVMC,
|
||||
CODEC_ID_H261,
|
||||
CODEC_ID_H263,
|
||||
CODEC_ID_RV10,
|
||||
CODEC_ID_RV20,
|
||||
CODEC_ID_MJPEG,
|
||||
CODEC_ID_MJPEGB,
|
||||
CODEC_ID_LJPEG,
|
||||
CODEC_ID_SP5X,
|
||||
CODEC_ID_JPEGLS,
|
||||
CODEC_ID_MPEG4,
|
||||
CODEC_ID_RAWVIDEO,
|
||||
CODEC_ID_MSMPEG4V1,
|
||||
CODEC_ID_MSMPEG4V2,
|
||||
CODEC_ID_MSMPEG4V3,
|
||||
CODEC_ID_WMV1,
|
||||
CODEC_ID_WMV2,
|
||||
CODEC_ID_H263P,
|
||||
CODEC_ID_H263I,
|
||||
CODEC_ID_FLV1,
|
||||
CODEC_ID_SVQ1,
|
||||
CODEC_ID_SVQ3,
|
||||
CODEC_ID_DVVIDEO,
|
||||
CODEC_ID_HUFFYUV,
|
||||
CODEC_ID_CYUV,
|
||||
CODEC_ID_H264,
|
||||
CODEC_ID_INDEO3,
|
||||
CODEC_ID_VP3,
|
||||
CODEC_ID_THEORA,
|
||||
CODEC_ID_ASV1,
|
||||
CODEC_ID_ASV2,
|
||||
CODEC_ID_FFV1,
|
||||
CODEC_ID_4XM,
|
||||
CODEC_ID_VCR1,
|
||||
CODEC_ID_CLJR,
|
||||
CODEC_ID_MDEC,
|
||||
CODEC_ID_ROQ,
|
||||
CODEC_ID_INTERPLAY_VIDEO,
|
||||
CODEC_ID_XAN_WC3,
|
||||
CODEC_ID_XAN_WC4,
|
||||
CODEC_ID_RPZA,
|
||||
CODEC_ID_CINEPAK,
|
||||
CODEC_ID_WS_VQA,
|
||||
CODEC_ID_MSRLE,
|
||||
CODEC_ID_MSVIDEO1,
|
||||
CODEC_ID_IDCIN,
|
||||
CODEC_ID_8BPS,
|
||||
CODEC_ID_SMC,
|
||||
CODEC_ID_FLIC,
|
||||
CODEC_ID_TRUEMOTION1,
|
||||
CODEC_ID_VMDVIDEO,
|
||||
CODEC_ID_MSZH,
|
||||
CODEC_ID_ZLIB,
|
||||
CODEC_ID_QTRLE,
|
||||
CODEC_ID_SNOW,
|
||||
CODEC_ID_TSCC,
|
||||
CODEC_ID_ULTI,
|
||||
CODEC_ID_QDRAW,
|
||||
CODEC_ID_VIXL,
|
||||
CODEC_ID_QPEG,
|
||||
CODEC_ID_PNG,
|
||||
CODEC_ID_PPM,
|
||||
CODEC_ID_PBM,
|
||||
CODEC_ID_PGM,
|
||||
CODEC_ID_PGMYUV,
|
||||
CODEC_ID_PAM,
|
||||
CODEC_ID_FFVHUFF,
|
||||
CODEC_ID_RV30,
|
||||
CODEC_ID_RV40,
|
||||
CODEC_ID_VC1,
|
||||
CODEC_ID_WMV3,
|
||||
CODEC_ID_LOCO,
|
||||
CODEC_ID_WNV1,
|
||||
CODEC_ID_AASC,
|
||||
CODEC_ID_INDEO2,
|
||||
CODEC_ID_FRAPS,
|
||||
CODEC_ID_TRUEMOTION2,
|
||||
CODEC_ID_BMP,
|
||||
CODEC_ID_CSCD,
|
||||
CODEC_ID_MMVIDEO,
|
||||
CODEC_ID_ZMBV,
|
||||
CODEC_ID_AVS,
|
||||
CODEC_ID_SMACKVIDEO,
|
||||
CODEC_ID_NUV,
|
||||
CODEC_ID_KMVC,
|
||||
CODEC_ID_FLASHSV,
|
||||
CODEC_ID_CAVS,
|
||||
CODEC_ID_JPEG2000,
|
||||
CODEC_ID_VMNC,
|
||||
CODEC_ID_VP5,
|
||||
CODEC_ID_VP6,
|
||||
CODEC_ID_VP6F,
|
||||
CODEC_ID_TARGA,
|
||||
CODEC_ID_DSICINVIDEO,
|
||||
CODEC_ID_TIERTEXSEQVIDEO,
|
||||
CODEC_ID_TIFF,
|
||||
CODEC_ID_GIF,
|
||||
CODEC_ID_DXA,
|
||||
CODEC_ID_DNXHD,
|
||||
CODEC_ID_THP,
|
||||
CODEC_ID_SGI,
|
||||
CODEC_ID_C93,
|
||||
CODEC_ID_BETHSOFTVID,
|
||||
CODEC_ID_PTX,
|
||||
CODEC_ID_TXD,
|
||||
CODEC_ID_VP6A,
|
||||
CODEC_ID_AMV,
|
||||
CODEC_ID_VB,
|
||||
CODEC_ID_PCX,
|
||||
CODEC_ID_SUNRAST,
|
||||
CODEC_ID_INDEO4,
|
||||
CODEC_ID_INDEO5,
|
||||
CODEC_ID_MIMIC,
|
||||
CODEC_ID_RL2,
|
||||
CODEC_ID_ESCAPE124,
|
||||
CODEC_ID_DIRAC,
|
||||
CODEC_ID_BFI,
|
||||
CODEC_ID_CMV,
|
||||
CODEC_ID_MOTIONPIXELS,
|
||||
CODEC_ID_TGV,
|
||||
CODEC_ID_TGQ,
|
||||
CODEC_ID_TQI,
|
||||
CODEC_ID_AURA,
|
||||
CODEC_ID_AURA2,
|
||||
CODEC_ID_V210X,
|
||||
CODEC_ID_TMV,
|
||||
CODEC_ID_V210,
|
||||
CODEC_ID_DPX,
|
||||
CODEC_ID_MAD,
|
||||
CODEC_ID_FRWU,
|
||||
CODEC_ID_FLASHSV2,
|
||||
CODEC_ID_CDGRAPHICS,
|
||||
CODEC_ID_R210,
|
||||
CODEC_ID_ANM,
|
||||
CODEC_ID_BINKVIDEO,
|
||||
CODEC_ID_IFF_ILBM,
|
||||
CODEC_ID_IFF_BYTERUN1,
|
||||
CODEC_ID_KGV1,
|
||||
CODEC_ID_YOP,
|
||||
CODEC_ID_VP8,
|
||||
CODEC_ID_PICTOR,
|
||||
CODEC_ID_ANSI,
|
||||
CODEC_ID_A64_MULTI,
|
||||
CODEC_ID_A64_MULTI5,
|
||||
CODEC_ID_R10K,
|
||||
CODEC_ID_MXPEG,
|
||||
CODEC_ID_LAGARITH,
|
||||
CODEC_ID_PRORES,
|
||||
CODEC_ID_JV,
|
||||
CODEC_ID_DFA,
|
||||
CODEC_ID_WMV3IMAGE,
|
||||
CODEC_ID_VC1IMAGE,
|
||||
CODEC_ID_UTVIDEO,
|
||||
CODEC_ID_BMV_VIDEO,
|
||||
CODEC_ID_VBLE,
|
||||
CODEC_ID_DXTORY,
|
||||
CODEC_ID_V410,
|
||||
CODEC_ID_XWD,
|
||||
CODEC_ID_CDXL,
|
||||
CODEC_ID_XBM,
|
||||
CODEC_ID_ZEROCODEC,
|
||||
CODEC_ID_MSS1,
|
||||
CODEC_ID_MSA1,
|
||||
CODEC_ID_TSCC2,
|
||||
CODEC_ID_MTS2,
|
||||
CODEC_ID_CLLC,
|
||||
CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
|
||||
CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
|
||||
CODEC_ID_EXR = MKBETAG('0','E','X','R'),
|
||||
CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
|
||||
|
||||
CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
|
||||
CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
|
||||
CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
|
||||
CODEC_ID_V308 = MKBETAG('V','3','0','8'),
|
||||
CODEC_ID_V408 = MKBETAG('V','4','0','8'),
|
||||
CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
|
||||
CODEC_ID_SANM = MKBETAG('S','A','N','M'),
|
||||
CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
|
||||
|
||||
/* various PCM "codecs" */
|
||||
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
CODEC_ID_PCM_S16LE = 0x10000,
|
||||
CODEC_ID_PCM_S16BE,
|
||||
CODEC_ID_PCM_U16LE,
|
||||
CODEC_ID_PCM_U16BE,
|
||||
CODEC_ID_PCM_S8,
|
||||
CODEC_ID_PCM_U8,
|
||||
CODEC_ID_PCM_MULAW,
|
||||
CODEC_ID_PCM_ALAW,
|
||||
CODEC_ID_PCM_S32LE,
|
||||
CODEC_ID_PCM_S32BE,
|
||||
CODEC_ID_PCM_U32LE,
|
||||
CODEC_ID_PCM_U32BE,
|
||||
CODEC_ID_PCM_S24LE,
|
||||
CODEC_ID_PCM_S24BE,
|
||||
CODEC_ID_PCM_U24LE,
|
||||
CODEC_ID_PCM_U24BE,
|
||||
CODEC_ID_PCM_S24DAUD,
|
||||
CODEC_ID_PCM_ZORK,
|
||||
CODEC_ID_PCM_S16LE_PLANAR,
|
||||
CODEC_ID_PCM_DVD,
|
||||
CODEC_ID_PCM_F32BE,
|
||||
CODEC_ID_PCM_F32LE,
|
||||
CODEC_ID_PCM_F64BE,
|
||||
CODEC_ID_PCM_F64LE,
|
||||
CODEC_ID_PCM_BLURAY,
|
||||
CODEC_ID_PCM_LXF,
|
||||
CODEC_ID_S302M,
|
||||
CODEC_ID_PCM_S8_PLANAR,
|
||||
|
||||
/* various ADPCM codecs */
|
||||
CODEC_ID_ADPCM_IMA_QT = 0x11000,
|
||||
CODEC_ID_ADPCM_IMA_WAV,
|
||||
CODEC_ID_ADPCM_IMA_DK3,
|
||||
CODEC_ID_ADPCM_IMA_DK4,
|
||||
CODEC_ID_ADPCM_IMA_WS,
|
||||
CODEC_ID_ADPCM_IMA_SMJPEG,
|
||||
CODEC_ID_ADPCM_MS,
|
||||
CODEC_ID_ADPCM_4XM,
|
||||
CODEC_ID_ADPCM_XA,
|
||||
CODEC_ID_ADPCM_ADX,
|
||||
CODEC_ID_ADPCM_EA,
|
||||
CODEC_ID_ADPCM_G726,
|
||||
CODEC_ID_ADPCM_CT,
|
||||
CODEC_ID_ADPCM_SWF,
|
||||
CODEC_ID_ADPCM_YAMAHA,
|
||||
CODEC_ID_ADPCM_SBPRO_4,
|
||||
CODEC_ID_ADPCM_SBPRO_3,
|
||||
CODEC_ID_ADPCM_SBPRO_2,
|
||||
CODEC_ID_ADPCM_THP,
|
||||
CODEC_ID_ADPCM_IMA_AMV,
|
||||
CODEC_ID_ADPCM_EA_R1,
|
||||
CODEC_ID_ADPCM_EA_R3,
|
||||
CODEC_ID_ADPCM_EA_R2,
|
||||
CODEC_ID_ADPCM_IMA_EA_SEAD,
|
||||
CODEC_ID_ADPCM_IMA_EA_EACS,
|
||||
CODEC_ID_ADPCM_EA_XAS,
|
||||
CODEC_ID_ADPCM_EA_MAXIS_XA,
|
||||
CODEC_ID_ADPCM_IMA_ISS,
|
||||
CODEC_ID_ADPCM_G722,
|
||||
CODEC_ID_ADPCM_IMA_APC,
|
||||
CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
|
||||
|
||||
/* AMR */
|
||||
CODEC_ID_AMR_NB = 0x12000,
|
||||
CODEC_ID_AMR_WB,
|
||||
|
||||
/* RealAudio codecs*/
|
||||
CODEC_ID_RA_144 = 0x13000,
|
||||
CODEC_ID_RA_288,
|
||||
|
||||
/* various DPCM codecs */
|
||||
CODEC_ID_ROQ_DPCM = 0x14000,
|
||||
CODEC_ID_INTERPLAY_DPCM,
|
||||
CODEC_ID_XAN_DPCM,
|
||||
CODEC_ID_SOL_DPCM,
|
||||
|
||||
/* audio codecs */
|
||||
CODEC_ID_MP2 = 0x15000,
|
||||
CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
|
||||
CODEC_ID_AAC,
|
||||
CODEC_ID_AC3,
|
||||
CODEC_ID_DTS,
|
||||
CODEC_ID_VORBIS,
|
||||
CODEC_ID_DVAUDIO,
|
||||
CODEC_ID_WMAV1,
|
||||
CODEC_ID_WMAV2,
|
||||
CODEC_ID_MACE3,
|
||||
CODEC_ID_MACE6,
|
||||
CODEC_ID_VMDAUDIO,
|
||||
CODEC_ID_FLAC,
|
||||
CODEC_ID_MP3ADU,
|
||||
CODEC_ID_MP3ON4,
|
||||
CODEC_ID_SHORTEN,
|
||||
CODEC_ID_ALAC,
|
||||
CODEC_ID_WESTWOOD_SND1,
|
||||
CODEC_ID_GSM, ///< as in Berlin toast format
|
||||
CODEC_ID_QDM2,
|
||||
CODEC_ID_COOK,
|
||||
CODEC_ID_TRUESPEECH,
|
||||
CODEC_ID_TTA,
|
||||
CODEC_ID_SMACKAUDIO,
|
||||
CODEC_ID_QCELP,
|
||||
CODEC_ID_WAVPACK,
|
||||
CODEC_ID_DSICINAUDIO,
|
||||
CODEC_ID_IMC,
|
||||
CODEC_ID_MUSEPACK7,
|
||||
CODEC_ID_MLP,
|
||||
CODEC_ID_GSM_MS, /* as found in WAV */
|
||||
CODEC_ID_ATRAC3,
|
||||
CODEC_ID_VOXWARE,
|
||||
CODEC_ID_APE,
|
||||
CODEC_ID_NELLYMOSER,
|
||||
CODEC_ID_MUSEPACK8,
|
||||
CODEC_ID_SPEEX,
|
||||
CODEC_ID_WMAVOICE,
|
||||
CODEC_ID_WMAPRO,
|
||||
CODEC_ID_WMALOSSLESS,
|
||||
CODEC_ID_ATRAC3P,
|
||||
CODEC_ID_EAC3,
|
||||
CODEC_ID_SIPR,
|
||||
CODEC_ID_MP1,
|
||||
CODEC_ID_TWINVQ,
|
||||
CODEC_ID_TRUEHD,
|
||||
CODEC_ID_MP4ALS,
|
||||
CODEC_ID_ATRAC1,
|
||||
CODEC_ID_BINKAUDIO_RDFT,
|
||||
CODEC_ID_BINKAUDIO_DCT,
|
||||
CODEC_ID_AAC_LATM,
|
||||
CODEC_ID_QDMC,
|
||||
CODEC_ID_CELT,
|
||||
CODEC_ID_G723_1,
|
||||
CODEC_ID_G729,
|
||||
CODEC_ID_8SVX_EXP,
|
||||
CODEC_ID_8SVX_FIB,
|
||||
CODEC_ID_BMV_AUDIO,
|
||||
CODEC_ID_RALF,
|
||||
CODEC_ID_IAC,
|
||||
CODEC_ID_ILBC,
|
||||
CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
|
||||
CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
|
||||
CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
|
||||
CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
|
||||
CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
|
||||
CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
|
||||
|
||||
/* subtitle codecs */
|
||||
CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
|
||||
CODEC_ID_DVD_SUBTITLE = 0x17000,
|
||||
CODEC_ID_DVB_SUBTITLE,
|
||||
CODEC_ID_TEXT, ///< raw UTF-8 text
|
||||
CODEC_ID_XSUB,
|
||||
CODEC_ID_SSA,
|
||||
CODEC_ID_MOV_TEXT,
|
||||
CODEC_ID_HDMV_PGS_SUBTITLE,
|
||||
CODEC_ID_DVB_TELETEXT,
|
||||
CODEC_ID_SRT,
|
||||
CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
|
||||
CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
|
||||
CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
|
||||
CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
|
||||
CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
|
||||
CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
|
||||
|
||||
/* other specific kind of codecs (generally used for attachments) */
|
||||
CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
|
||||
CODEC_ID_TTF = 0x18000,
|
||||
CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
|
||||
CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
|
||||
CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
|
||||
CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
|
||||
|
||||
CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
|
||||
|
||||
CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
|
||||
* stream (only used by libavformat) */
|
||||
CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
|
||||
* stream (only used by libavformat) */
|
||||
CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
|
||||
|
||||
#endif /* AVCODEC_OLD_CODEC_IDS_H */
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Video Acceleration API (shared data between FFmpeg and the video player)
|
||||
* HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
|
||||
*
|
||||
* Copyright (C) 2008-2009 Splitted-Desktop Systems
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VAAPI_H
|
||||
#define AVCODEC_VAAPI_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vaapi
|
||||
* Public libavcodec VA API header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vaapi VA API Decoding
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This structure is used to share data between the FFmpeg library and
|
||||
* the client video application.
|
||||
* This shall be zero-allocated and available as
|
||||
* AVCodecContext.hwaccel_context. All user members can be set once
|
||||
* during initialization or through each AVCodecContext.get_buffer()
|
||||
* function call. In any case, they must be valid prior to calling
|
||||
* decoding functions.
|
||||
*/
|
||||
struct vaapi_context {
|
||||
/**
|
||||
* Window system dependent data
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
void *display;
|
||||
|
||||
/**
|
||||
* Configuration ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
uint32_t config_id;
|
||||
|
||||
/**
|
||||
* Context ID (video decode pipeline)
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
uint32_t context_id;
|
||||
|
||||
/**
|
||||
* VAPictureParameterBuffer ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t pic_param_buf_id;
|
||||
|
||||
/**
|
||||
* VAIQMatrixBuffer ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t iq_matrix_buf_id;
|
||||
|
||||
/**
|
||||
* VABitPlaneBuffer ID (for VC-1 decoding)
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t bitplane_buf_id;
|
||||
|
||||
/**
|
||||
* Slice parameter/data buffer IDs
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t *slice_buf_ids;
|
||||
|
||||
/**
|
||||
* Number of effective slice buffer IDs to send to the HW
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int n_slice_buf_ids;
|
||||
|
||||
/**
|
||||
* Size of pre-allocated slice_buf_ids
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_buf_ids_alloc;
|
||||
|
||||
/**
|
||||
* Pointer to VASliceParameterBuffers
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
void *slice_params;
|
||||
|
||||
/**
|
||||
* Size of a VASliceParameterBuffer element
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_param_size;
|
||||
|
||||
/**
|
||||
* Size of pre-allocated slice_params
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_params_alloc;
|
||||
|
||||
/**
|
||||
* Number of slices currently filled in
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_count;
|
||||
|
||||
/**
|
||||
* Pointer to slice data buffer base
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
const uint8_t *slice_data;
|
||||
|
||||
/**
|
||||
* Current size of slice data
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t slice_data_size;
|
||||
};
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* AVCODEC_VAAPI_H */
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
* VDA HW acceleration
|
||||
*
|
||||
* copyright (c) 2011 Sebastien Zwickert
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDA_H
|
||||
#define AVCODEC_VDA_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vda
|
||||
* Public libavcodec VDA header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
|
||||
// http://openradar.appspot.com/8026390
|
||||
#undef __GNUC_STDC_INLINE__
|
||||
|
||||
#define Picture QuickdrawPicture
|
||||
#include <VideoDecodeAcceleration/VDADecoder.h>
|
||||
#undef Picture
|
||||
|
||||
#include "libavcodec/version.h"
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vda VDA
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
/**
|
||||
* This structure is used to store decoded frame information and data.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* The PTS of the frame.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int64_t pts;
|
||||
|
||||
/**
|
||||
* The CoreVideo buffer that contains the decoded data.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
CVPixelBufferRef cv_buffer;
|
||||
|
||||
/**
|
||||
* A pointer to the next frame.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
struct vda_frame *next_frame;
|
||||
} vda_frame;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This structure is used to provide the necessary configurations and data
|
||||
* to the VDA FFmpeg HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct vda_context {
|
||||
/**
|
||||
* VDA decoder object.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
VDADecoder decoder;
|
||||
|
||||
/**
|
||||
* The Core Video pixel buffer that contains the current image data.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by libavcodec. Unset by user.
|
||||
*/
|
||||
CVPixelBufferRef cv_buffer;
|
||||
|
||||
/**
|
||||
* Use the hardware decoder in synchronous mode.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by user.
|
||||
*/
|
||||
int use_sync_decoding;
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
/**
|
||||
* VDA frames queue ordered by presentation timestamp.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
vda_frame *queue;
|
||||
|
||||
/**
|
||||
* Mutex for locking queue operations.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
pthread_mutex_t queue_mutex;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The frame width.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int width;
|
||||
|
||||
/**
|
||||
* The frame height.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int height;
|
||||
|
||||
/**
|
||||
* The frame format.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int format;
|
||||
|
||||
/**
|
||||
* The pixel format for output image buffers.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
OSType cv_pix_fmt_type;
|
||||
|
||||
/**
|
||||
* The current bitstream buffer.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
uint8_t *priv_bitstream;
|
||||
|
||||
/**
|
||||
* The current size of the bitstream.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int priv_bitstream_size;
|
||||
|
||||
/**
|
||||
* The reference size used for fast reallocation.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int priv_allocated_size;
|
||||
};
|
||||
|
||||
/** Create the video decoder. */
|
||||
int ff_vda_create_decoder(struct vda_context *vda_ctx,
|
||||
uint8_t *extradata,
|
||||
int extradata_size);
|
||||
|
||||
/** Destroy the video decoder. */
|
||||
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
/**
|
||||
* Return the top frame of the queue.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*/
|
||||
vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
|
||||
|
||||
/**
|
||||
* Release the given frame.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*/
|
||||
void ff_vda_release_vda_frame(vda_frame *frame);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_VDA_H */
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* The Video Decode and Presentation API for UNIX (VDPAU) is used for
|
||||
* hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1.
|
||||
*
|
||||
* Copyright (C) 2008 NVIDIA
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDPAU_H
|
||||
#define AVCODEC_VDPAU_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vdpau
|
||||
* Public libavcodec VDPAU header.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* VDPAU hardware acceleration has two modules
|
||||
* - VDPAU decoding
|
||||
* - VDPAU presentation
|
||||
*
|
||||
* The VDPAU decoding module parses all headers using FFmpeg
|
||||
* parsing mechanisms and uses VDPAU for the actual decoding.
|
||||
*
|
||||
* As per the current implementation, the actual decoding
|
||||
* and rendering (API calls) are done as part of the VDPAU
|
||||
* presentation (vo_vdpau.c) module.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <vdpau/vdpau.h>
|
||||
#include <vdpau/vdpau_x11.h>
|
||||
|
||||
/** @brief The videoSurface is used for rendering. */
|
||||
#define FF_VDPAU_STATE_USED_FOR_RENDER 1
|
||||
|
||||
/**
|
||||
* @brief The videoSurface is needed for reference/prediction.
|
||||
* The codec manipulates this.
|
||||
*/
|
||||
#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2
|
||||
|
||||
/**
|
||||
* @brief This structure is used as a callback between the FFmpeg
|
||||
* decoder (vd_) and presentation (vo_) module.
|
||||
* This is used for defining a video frame containing surface,
|
||||
* picture parameter, bitstream information etc which are passed
|
||||
* between the FFmpeg decoder and its clients.
|
||||
*/
|
||||
struct vdpau_render_state {
|
||||
VdpVideoSurface surface; ///< Used as rendered surface, never changed.
|
||||
|
||||
int state; ///< Holds FF_VDPAU_STATE_* values.
|
||||
|
||||
/** Describe size/location of the compressed video data.
|
||||
Set to 0 when freeing bitstream_buffers. */
|
||||
int bitstream_buffers_allocated;
|
||||
int bitstream_buffers_used;
|
||||
/** The user is responsible for freeing this buffer using av_freep(). */
|
||||
VdpBitstreamBuffer *bitstream_buffers;
|
||||
|
||||
/** picture parameter information for all supported codecs */
|
||||
union VdpPictureInfo {
|
||||
VdpPictureInfoH264 h264;
|
||||
VdpPictureInfoMPEG1Or2 mpeg;
|
||||
VdpPictureInfoVC1 vc1;
|
||||
VdpPictureInfoMPEG4Part2 mpeg4;
|
||||
} info;
|
||||
};
|
||||
|
||||
/* @}*/
|
||||
|
||||
#endif /* AVCODEC_VDPAU_H */
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VERSION_H
|
||||
#define AVCODEC_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavc
|
||||
* Libavcodec version macros.
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 54
|
||||
#define LIBAVCODEC_VERSION_MINOR 80
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
|
||||
|
||||
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#ifndef FF_API_REQUEST_CHANNELS
|
||||
#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_ALLOC_CONTEXT
|
||||
#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_OPEN
|
||||
#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_DECODE_AUDIO
|
||||
#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_TIMECODE
|
||||
#define FF_API_OLD_TIMECODE (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
|
||||
#ifndef FF_API_OLD_ENCODE_AUDIO
|
||||
#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_ENCODE_VIDEO
|
||||
#define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_MPV_GLOBAL_OPTS
|
||||
#define FF_API_MPV_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_COLOR_TABLE_ID
|
||||
#define FF_API_COLOR_TABLE_ID (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_INTER_THRESHOLD
|
||||
#define FF_API_INTER_THRESHOLD (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_SUB_ID
|
||||
#define FF_API_SUB_ID (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_DSP_MASK
|
||||
#define FF_API_DSP_MASK (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_FIND_BEST_PIX_FMT
|
||||
#define FF_API_FIND_BEST_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_CODEC_ID
|
||||
#define FF_API_CODEC_ID (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_VDA_ASYNC
|
||||
#define FF_API_VDA_ASYNC (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_RESAMPLE
|
||||
#define FF_API_AVCODEC_RESAMPLE (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_LIBMPEG2
|
||||
#define FF_API_LIBMPEG2 (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_MMI
|
||||
#define FF_API_MMI (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_VERSION_H */
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Ivan Kalvachev
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_XVMC_H
|
||||
#define AVCODEC_XVMC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_xvmc
|
||||
* Public libavcodec XvMC header.
|
||||
*/
|
||||
|
||||
#include <X11/extensions/XvMC.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_xvmc XvMC
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct
|
||||
the number is 1337 speak for the letters IDCT MCo (motion compensation) */
|
||||
|
||||
struct xvmc_pix_fmt {
|
||||
/** The field contains the special constant value AV_XVMC_ID.
|
||||
It is used as a test that the application correctly uses the API,
|
||||
and that there is no corruption caused by pixel routines.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int xvmc_id;
|
||||
|
||||
/** Pointer to the block array allocated by XvMCCreateBlocks().
|
||||
The array has to be freed by XvMCDestroyBlocks().
|
||||
Each group of 64 values represents one data block of differential
|
||||
pixel information (in MoCo mode) or coefficients for IDCT.
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills coefficients/pixel data into the array
|
||||
*/
|
||||
short* data_blocks;
|
||||
|
||||
/** Pointer to the macroblock description array allocated by
|
||||
XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks().
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills description data into the array
|
||||
*/
|
||||
XvMCMacroBlock* mv_blocks;
|
||||
|
||||
/** Number of macroblock descriptions that can be stored in the mv_blocks
|
||||
array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_mv_blocks;
|
||||
|
||||
/** Number of blocks that can be stored at once in the data_blocks array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_data_blocks;
|
||||
|
||||
/** Indicate that the hardware would interpret data_blocks as IDCT
|
||||
coefficients and perform IDCT on them.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int idct;
|
||||
|
||||
/** In MoCo mode it indicates that intra macroblocks are assumed to be in
|
||||
unsigned format; same as the XVMC_INTRA_UNSIGNED flag.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int unsigned_intra;
|
||||
|
||||
/** Pointer to the surface allocated by XvMCCreateSurface().
|
||||
It has to be freed by XvMCDestroySurface() on application exit.
|
||||
It identifies the frame and its state on the video hardware.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
XvMCSurface* p_surface;
|
||||
|
||||
/** Set by the decoder before calling ff_draw_horiz_band(),
|
||||
needed by the XvMCRenderSurface function. */
|
||||
//@{
|
||||
/** Pointer to the surface used as past reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_past_surface;
|
||||
|
||||
/** Pointer to the surface used as future reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_future_surface;
|
||||
|
||||
/** top/bottom field or frame
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int picture_structure;
|
||||
|
||||
/** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int flags;
|
||||
//}@
|
||||
|
||||
/** Number of macroblock descriptions in the mv_blocks array
|
||||
that have already been passed to the hardware.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may increment it
|
||||
with filled_mb_block_num or zero both.
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int start_mv_blocks_num;
|
||||
|
||||
/** Number of new macroblock descriptions in the mv_blocks array (after
|
||||
start_mv_blocks_num) that are filled by libavcodec and have to be
|
||||
passed to the hardware.
|
||||
- application - zeroes it on get_buffer() or after successful
|
||||
ff_draw_horiz_band().
|
||||
- libavcodec - increment with one of each stored MB
|
||||
*/
|
||||
int filled_mv_blocks_num;
|
||||
|
||||
/** Number of the next free data block; one data block consists of
|
||||
64 short values in the data_blocks array.
|
||||
All blocks before this one have already been claimed by placing their
|
||||
position into the corresponding block description structure field,
|
||||
that are part of the mv_blocks array.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may zero it together
|
||||
with start_mb_blocks_num.
|
||||
- libavcodec - each decoded macroblock increases it by the number
|
||||
of coded blocks it contains.
|
||||
*/
|
||||
int next_free_data_block_num;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_XVMC_H */
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVDEVICE_AVDEVICE_H
|
||||
#define AVDEVICE_AVDEVICE_H
|
||||
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavd
|
||||
* Main libavdevice API header
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavd Special devices muxing/demuxing library
|
||||
* @{
|
||||
* Libavdevice is a complementary library to @ref libavf "libavformat". It
|
||||
* provides various "special" platform-specific muxers and demuxers, e.g. for
|
||||
* grabbing devices, audio capture and playback etc. As a consequence, the
|
||||
* (de)muxers in libavdevice are of the AVFMT_NOFILE type (they use their own
|
||||
* I/O functions). The filename passed to avformat_open_input() often does not
|
||||
* refer to an actually existing file, but has some special device-specific
|
||||
* meaning - e.g. for x11grab it is the display name.
|
||||
*
|
||||
* To use libavdevice, simply call avdevice_register_all() to register all
|
||||
* compiled muxers and demuxers. They all use standard libavformat API.
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
|
||||
/**
|
||||
* Return the LIBAVDEVICE_VERSION_INT constant.
|
||||
*/
|
||||
unsigned avdevice_version(void);
|
||||
|
||||
/**
|
||||
* Return the libavdevice build-time configuration.
|
||||
*/
|
||||
const char *avdevice_configuration(void);
|
||||
|
||||
/**
|
||||
* Return the libavdevice license.
|
||||
*/
|
||||
const char *avdevice_license(void);
|
||||
|
||||
/**
|
||||
* Initialize libavdevice and register all the input and output devices.
|
||||
* @warning This function is not thread safe.
|
||||
*/
|
||||
void avdevice_register_all(void);
|
||||
|
||||
#endif /* AVDEVICE_AVDEVICE_H */
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVDEVICE_VERSION_H
|
||||
#define AVDEVICE_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavd
|
||||
* Libavdevice version macros
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVDEVICE_VERSION_MAJOR 54
|
||||
#define LIBAVDEVICE_VERSION_MINOR 3
|
||||
#define LIBAVDEVICE_VERSION_MICRO 102
|
||||
|
||||
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
|
||||
LIBAVDEVICE_VERSION_MINOR, \
|
||||
LIBAVDEVICE_VERSION_MICRO)
|
||||
#define LIBAVDEVICE_VERSION AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, \
|
||||
LIBAVDEVICE_VERSION_MINOR, \
|
||||
LIBAVDEVICE_VERSION_MICRO)
|
||||
#define LIBAVDEVICE_BUILD LIBAVDEVICE_VERSION_INT
|
||||
|
||||
#define LIBAVDEVICE_IDENT "Lavd" AV_STRINGIFY(LIBAVDEVICE_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#endif /* AVDEVICE_VERSION_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,475 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef AVFORMAT_AVIO_H
|
||||
#define AVFORMAT_AVIO_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavf_io
|
||||
* Buffered I/O operations
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "libavformat/version.h"
|
||||
|
||||
|
||||
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
|
||||
|
||||
/**
|
||||
* Callback for checking whether to abort blocking functions.
|
||||
* AVERROR_EXIT is returned in this case by the interrupted
|
||||
* function. During blocking operations, callback is called with
|
||||
* opaque as parameter. If the callback returns 1, the
|
||||
* blocking operation will be aborted.
|
||||
*
|
||||
* No members can be added to this struct without a major bump, if
|
||||
* new elements have been added after this struct in AVFormatContext
|
||||
* or AVIOContext.
|
||||
*/
|
||||
typedef struct AVIOInterruptCB {
|
||||
int (*callback)(void*);
|
||||
void *opaque;
|
||||
} AVIOInterruptCB;
|
||||
|
||||
/**
|
||||
* Bytestream IO Context.
|
||||
* New fields can be added to the end with minor version bumps.
|
||||
* Removal, reordering and changes to existing fields require a major
|
||||
* version bump.
|
||||
* sizeof(AVIOContext) must not be used outside libav*.
|
||||
*
|
||||
* @note None of the function pointers in AVIOContext should be called
|
||||
* directly, they should only be set by the client application
|
||||
* when implementing custom I/O. Normally these are set to the
|
||||
* function pointers specified in avio_alloc_context()
|
||||
*/
|
||||
typedef struct AVIOContext {
|
||||
/**
|
||||
* A class for private options.
|
||||
*
|
||||
* If this AVIOContext is created by avio_open2(), av_class is set and
|
||||
* passes the options down to protocols.
|
||||
*
|
||||
* If this AVIOContext is manually allocated, then av_class may be set by
|
||||
* the caller.
|
||||
*
|
||||
* warning -- this field can be NULL, be sure to not pass this AVIOContext
|
||||
* to any av_opt_* functions in that case.
|
||||
*/
|
||||
const AVClass *av_class;
|
||||
unsigned char *buffer; /**< Start of the buffer. */
|
||||
int buffer_size; /**< Maximum buffer size */
|
||||
unsigned char *buf_ptr; /**< Current position in the buffer */
|
||||
unsigned char *buf_end; /**< End of the data, may be less than
|
||||
buffer+buffer_size if the read function returned
|
||||
less data than requested, e.g. for streams where
|
||||
no more data has been received yet. */
|
||||
void *opaque; /**< A private pointer, passed to the read/write/seek/...
|
||||
functions. */
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence);
|
||||
int64_t pos; /**< position in the file of the current buffer */
|
||||
int must_flush; /**< true if the next seek should flush */
|
||||
int eof_reached; /**< true if eof reached */
|
||||
int write_flag; /**< true if open for writing */
|
||||
int max_packet_size;
|
||||
unsigned long checksum;
|
||||
unsigned char *checksum_ptr;
|
||||
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
|
||||
int error; /**< contains the error code or 0 if no error happened */
|
||||
/**
|
||||
* Pause or resume playback for network streaming protocols - e.g. MMS.
|
||||
*/
|
||||
int (*read_pause)(void *opaque, int pause);
|
||||
/**
|
||||
* Seek to a given timestamp in stream with the specified stream_index.
|
||||
* Needed for some network streaming protocols which don't support seeking
|
||||
* to byte position.
|
||||
*/
|
||||
int64_t (*read_seek)(void *opaque, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
/**
|
||||
* A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
|
||||
*/
|
||||
int seekable;
|
||||
|
||||
/**
|
||||
* max filesize, used to limit allocations
|
||||
* This field is internal to libavformat and access from outside is not allowed.
|
||||
*/
|
||||
int64_t maxsize;
|
||||
|
||||
/**
|
||||
* avio_read and avio_write should if possible be satisfied directly
|
||||
* instead of going through a buffer, and avio_seek will always
|
||||
* call the underlying seek function directly.
|
||||
*/
|
||||
int direct;
|
||||
|
||||
/**
|
||||
* Bytes read statistic
|
||||
* This field is internal to libavformat and access from outside is not allowed.
|
||||
*/
|
||||
int64_t bytes_read;
|
||||
|
||||
/**
|
||||
* seek statistic
|
||||
* This field is internal to libavformat and access from outside is not allowed.
|
||||
*/
|
||||
int seek_count;
|
||||
} AVIOContext;
|
||||
|
||||
/* unbuffered I/O */
|
||||
|
||||
/**
|
||||
* Return AVIO_FLAG_* access flags corresponding to the access permissions
|
||||
* of the resource in url, or a negative value corresponding to an
|
||||
* AVERROR code in case of failure. The returned access flags are
|
||||
* masked by the value in flags.
|
||||
*
|
||||
* @note This function is intrinsically unsafe, in the sense that the
|
||||
* checked resource may change its existence or permission status from
|
||||
* one call to another. Thus you should not trust the returned value,
|
||||
* unless you are sure that no other processes are accessing the
|
||||
* checked resource.
|
||||
*/
|
||||
int avio_check(const char *url, int flags);
|
||||
|
||||
/**
|
||||
* Allocate and initialize an AVIOContext for buffered I/O. It must be later
|
||||
* freed with av_free().
|
||||
*
|
||||
* @param buffer Memory block for input/output operations via AVIOContext.
|
||||
* The buffer must be allocated with av_malloc() and friends.
|
||||
* @param buffer_size The buffer size is very important for performance.
|
||||
* For protocols with fixed blocksize it should be set to this blocksize.
|
||||
* For others a typical size is a cache page, e.g. 4kb.
|
||||
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
|
||||
* @param opaque An opaque pointer to user-specific data.
|
||||
* @param read_packet A function for refilling the buffer, may be NULL.
|
||||
* @param write_packet A function for writing the buffer contents, may be NULL.
|
||||
* The function may not change the input buffers content.
|
||||
* @param seek A function for seeking to specified byte position, may be NULL.
|
||||
*
|
||||
* @return Allocated AVIOContext or NULL on failure.
|
||||
*/
|
||||
AVIOContext *avio_alloc_context(
|
||||
unsigned char *buffer,
|
||||
int buffer_size,
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence));
|
||||
|
||||
void avio_w8(AVIOContext *s, int b);
|
||||
void avio_write(AVIOContext *s, const unsigned char *buf, int size);
|
||||
void avio_wl64(AVIOContext *s, uint64_t val);
|
||||
void avio_wb64(AVIOContext *s, uint64_t val);
|
||||
void avio_wl32(AVIOContext *s, unsigned int val);
|
||||
void avio_wb32(AVIOContext *s, unsigned int val);
|
||||
void avio_wl24(AVIOContext *s, unsigned int val);
|
||||
void avio_wb24(AVIOContext *s, unsigned int val);
|
||||
void avio_wl16(AVIOContext *s, unsigned int val);
|
||||
void avio_wb16(AVIOContext *s, unsigned int val);
|
||||
|
||||
/**
|
||||
* Write a NULL-terminated string.
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
int avio_put_str(AVIOContext *s, const char *str);
|
||||
|
||||
/**
|
||||
* Convert an UTF-8 string to UTF-16LE and write it.
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
int avio_put_str16le(AVIOContext *s, const char *str);
|
||||
|
||||
/**
|
||||
* Passing this as the "whence" parameter to a seek function causes it to
|
||||
* return the filesize without seeking anywhere. Supporting this is optional.
|
||||
* If it is not supported then the seek function will return <0.
|
||||
*/
|
||||
#define AVSEEK_SIZE 0x10000
|
||||
|
||||
/**
|
||||
* Oring this flag as into the "whence" parameter to a seek function causes it to
|
||||
* seek by any means (like reopening and linear reading) or other normally unreasonble
|
||||
* means that can be extreemly slow.
|
||||
* This may be ignored by the seek code.
|
||||
*/
|
||||
#define AVSEEK_FORCE 0x20000
|
||||
|
||||
/**
|
||||
* fseek() equivalent for AVIOContext.
|
||||
* @return new position or AVERROR.
|
||||
*/
|
||||
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
|
||||
|
||||
/**
|
||||
* Skip given number of bytes forward
|
||||
* @return new position or AVERROR.
|
||||
*/
|
||||
int64_t avio_skip(AVIOContext *s, int64_t offset);
|
||||
|
||||
/**
|
||||
* ftell() equivalent for AVIOContext.
|
||||
* @return position or AVERROR.
|
||||
*/
|
||||
static av_always_inline int64_t avio_tell(AVIOContext *s)
|
||||
{
|
||||
return avio_seek(s, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filesize.
|
||||
* @return filesize or AVERROR
|
||||
*/
|
||||
int64_t avio_size(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* feof() equivalent for AVIOContext.
|
||||
* @return non zero if and only if end of file
|
||||
*/
|
||||
int url_feof(AVIOContext *s);
|
||||
|
||||
/** @warning currently size is limited */
|
||||
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
|
||||
|
||||
/**
|
||||
* Force flushing of buffered data to the output s.
|
||||
*
|
||||
* Force the buffered data to be immediately written to the output,
|
||||
* without to wait to fill the internal buffer.
|
||||
*/
|
||||
void avio_flush(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Read size bytes from AVIOContext into buf.
|
||||
* @return number of bytes read or AVERROR
|
||||
*/
|
||||
int avio_read(AVIOContext *s, unsigned char *buf, int size);
|
||||
|
||||
/**
|
||||
* @name Functions for reading from AVIOContext
|
||||
* @{
|
||||
*
|
||||
* @note return 0 if EOF, so you cannot use it if EOF handling is
|
||||
* necessary
|
||||
*/
|
||||
int avio_r8 (AVIOContext *s);
|
||||
unsigned int avio_rl16(AVIOContext *s);
|
||||
unsigned int avio_rl24(AVIOContext *s);
|
||||
unsigned int avio_rl32(AVIOContext *s);
|
||||
uint64_t avio_rl64(AVIOContext *s);
|
||||
unsigned int avio_rb16(AVIOContext *s);
|
||||
unsigned int avio_rb24(AVIOContext *s);
|
||||
unsigned int avio_rb32(AVIOContext *s);
|
||||
uint64_t avio_rb64(AVIOContext *s);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read a string from pb into buf. The reading will terminate when either
|
||||
* a NULL character was encountered, maxlen bytes have been read, or nothing
|
||||
* more can be read from pb. The result is guaranteed to be NULL-terminated, it
|
||||
* will be truncated if buf is too small.
|
||||
* Note that the string is not interpreted or validated in any way, it
|
||||
* might get truncated in the middle of a sequence for multi-byte encodings.
|
||||
*
|
||||
* @return number of bytes read (is always <= maxlen).
|
||||
* If reading ends on EOF or error, the return value will be one more than
|
||||
* bytes actually read.
|
||||
*/
|
||||
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
|
||||
/**
|
||||
* Read a UTF-16 string from pb and convert it to UTF-8.
|
||||
* The reading will terminate when either a null or invalid character was
|
||||
* encountered or maxlen bytes have been read.
|
||||
* @return number of bytes read (is always <= maxlen)
|
||||
*/
|
||||
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
|
||||
|
||||
/**
|
||||
* @name URL open modes
|
||||
* The flags argument to avio_open must be one of the following
|
||||
* constants, optionally ORed with other flags.
|
||||
* @{
|
||||
*/
|
||||
#define AVIO_FLAG_READ 1 /**< read-only */
|
||||
#define AVIO_FLAG_WRITE 2 /**< write-only */
|
||||
#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use non-blocking mode.
|
||||
* If this flag is set, operations on the context will return
|
||||
* AVERROR(EAGAIN) if they can not be performed immediately.
|
||||
* If this flag is not set, operations on the context will never return
|
||||
* AVERROR(EAGAIN).
|
||||
* Note that this flag does not affect the opening/connecting of the
|
||||
* context. Connecting a protocol will always block if necessary (e.g. on
|
||||
* network protocols) but never hang (e.g. on busy devices).
|
||||
* Warning: non-blocking protocols is work-in-progress; this flag may be
|
||||
* silently ignored.
|
||||
*/
|
||||
#define AVIO_FLAG_NONBLOCK 8
|
||||
|
||||
/**
|
||||
* Use direct mode.
|
||||
* avio_read and avio_write should if possible be satisfied directly
|
||||
* instead of going through a buffer, and avio_seek will always
|
||||
* call the underlying seek function directly.
|
||||
*/
|
||||
#define AVIO_FLAG_DIRECT 0x8000
|
||||
|
||||
/**
|
||||
* Create and initialize a AVIOContext for accessing the
|
||||
* resource indicated by url.
|
||||
* @note When the resource indicated by url has been opened in
|
||||
* read+write mode, the AVIOContext can be used only for writing.
|
||||
*
|
||||
* @param s Used to return the pointer to the created AVIOContext.
|
||||
* In case of failure the pointed to value is set to NULL.
|
||||
* @param flags flags which control how the resource indicated by url
|
||||
* is to be opened
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code in case of failure
|
||||
*/
|
||||
int avio_open(AVIOContext **s, const char *url, int flags);
|
||||
|
||||
/**
|
||||
* Create and initialize a AVIOContext for accessing the
|
||||
* resource indicated by url.
|
||||
* @note When the resource indicated by url has been opened in
|
||||
* read+write mode, the AVIOContext can be used only for writing.
|
||||
*
|
||||
* @param s Used to return the pointer to the created AVIOContext.
|
||||
* In case of failure the pointed to value is set to NULL.
|
||||
* @param flags flags which control how the resource indicated by url
|
||||
* is to be opened
|
||||
* @param int_cb an interrupt callback to be used at the protocols level
|
||||
* @param options A dictionary filled with protocol-private options. On return
|
||||
* this parameter will be destroyed and replaced with a dict containing options
|
||||
* that were not found. May be NULL.
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code in case of failure
|
||||
*/
|
||||
int avio_open2(AVIOContext **s, const char *url, int flags,
|
||||
const AVIOInterruptCB *int_cb, AVDictionary **options);
|
||||
|
||||
/**
|
||||
* Close the resource accessed by the AVIOContext s and free it.
|
||||
* This function can only be used if s was opened by avio_open().
|
||||
*
|
||||
* The internal buffer is automatically flushed before closing the
|
||||
* resource.
|
||||
*
|
||||
* @return 0 on success, an AVERROR < 0 on error.
|
||||
* @see avio_closep
|
||||
*/
|
||||
int avio_close(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Close the resource accessed by the AVIOContext *s, free it
|
||||
* and set the pointer pointing to it to NULL.
|
||||
* This function can only be used if s was opened by avio_open().
|
||||
*
|
||||
* The internal buffer is automatically flushed before closing the
|
||||
* resource.
|
||||
*
|
||||
* @return 0 on success, an AVERROR < 0 on error.
|
||||
* @see avio_close
|
||||
*/
|
||||
int avio_closep(AVIOContext **s);
|
||||
|
||||
|
||||
/**
|
||||
* Open a write only memory stream.
|
||||
*
|
||||
* @param s new IO context
|
||||
* @return zero if no error.
|
||||
*/
|
||||
int avio_open_dyn_buf(AVIOContext **s);
|
||||
|
||||
/**
|
||||
* Return the written size and a pointer to the buffer. The buffer
|
||||
* must be freed with av_free().
|
||||
* Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
|
||||
*
|
||||
* @param s IO context
|
||||
* @param pbuffer pointer to a byte buffer
|
||||
* @return the length of the byte buffer
|
||||
*/
|
||||
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
||||
|
||||
/**
|
||||
* Iterate through names of available protocols.
|
||||
*
|
||||
* @param opaque A private pointer representing current protocol.
|
||||
* It must be a pointer to NULL on first iteration and will
|
||||
* be updated by successive calls to avio_enum_protocols.
|
||||
* @param output If set to 1, iterate over output protocols,
|
||||
* otherwise over input protocols.
|
||||
*
|
||||
* @return A static string containing the name of current protocol or NULL
|
||||
*/
|
||||
const char *avio_enum_protocols(void **opaque, int output);
|
||||
|
||||
/**
|
||||
* Pause and resume playing - only meaningful if using a network streaming
|
||||
* protocol (e.g. MMS).
|
||||
* @param pause 1 for pause, 0 for resume
|
||||
*/
|
||||
int avio_pause(AVIOContext *h, int pause);
|
||||
|
||||
/**
|
||||
* Seek to a given timestamp relative to some component stream.
|
||||
* Only meaningful if using a network streaming protocol (e.g. MMS.).
|
||||
* @param stream_index The stream index that the timestamp is relative to.
|
||||
* If stream_index is (-1) the timestamp should be in AV_TIME_BASE
|
||||
* units from the beginning of the presentation.
|
||||
* If a stream_index >= 0 is used and the protocol does not support
|
||||
* seeking based on component streams, the call will fail.
|
||||
* @param timestamp timestamp in AVStream.time_base units
|
||||
* or if there is no stream specified then in AV_TIME_BASE units.
|
||||
* @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
|
||||
* and AVSEEK_FLAG_ANY. The protocol may silently ignore
|
||||
* AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
|
||||
* fail if used and not supported.
|
||||
* @return >= 0 on success
|
||||
* @see AVInputFormat::read_seek
|
||||
*/
|
||||
int64_t avio_seek_time(AVIOContext *h, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
|
||||
#endif /* AVFORMAT_AVIO_H */
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Version macros.
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFORMAT_VERSION_H
|
||||
#define AVFORMAT_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavf
|
||||
* Libavformat version macros
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 54
|
||||
#define LIBAVFORMAT_VERSION_MINOR 49
|
||||
#define LIBAVFORMAT_VERSION_MICRO 102
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
LIBAVFORMAT_VERSION_MICRO)
|
||||
#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
LIBAVFORMAT_VERSION_MICRO)
|
||||
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
|
||||
|
||||
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#ifndef FF_API_OLD_AVIO
|
||||
#define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_PKT_DUMP
|
||||
#define FF_API_PKT_DUMP (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_ALLOC_OUTPUT_CONTEXT
|
||||
#define FF_API_ALLOC_OUTPUT_CONTEXT (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_FORMAT_PARAMETERS
|
||||
#define FF_API_FORMAT_PARAMETERS (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_NEW_STREAM
|
||||
#define FF_API_NEW_STREAM (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_SET_PTS_INFO
|
||||
#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_CLOSE_INPUT_FILE
|
||||
#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_APPLEHTTP_PROTO
|
||||
#define FF_API_APPLEHTTP_PROTO (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_READ_PACKET
|
||||
#define FF_API_READ_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_INTERLEAVE_PACKET
|
||||
#define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_AV_GETTIME
|
||||
#define FF_API_AV_GETTIME (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_R_FRAME_RATE
|
||||
#define FF_API_R_FRAME_RATE (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
|
||||
#endif /* AVFORMAT_VERSION_H */
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 Mans Rullgard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ADLER32_H
|
||||
#define AVUTIL_ADLER32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @ingroup lavu_crypto
|
||||
* Calculate the Adler32 checksum of a buffer.
|
||||
*
|
||||
* Passing the return value to a subsequent av_adler32_update() call
|
||||
* allows the checksum of multiple buffers to be calculated as though
|
||||
* they were concatenated.
|
||||
*
|
||||
* @param adler initial checksum value
|
||||
* @param buf pointer to input buffer
|
||||
* @param len size of input buffer
|
||||
* @return updated checksum
|
||||
*/
|
||||
unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
|
||||
unsigned int len) av_pure;
|
||||
|
||||
#endif /* AVUTIL_ADLER32_H */
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AES_H
|
||||
#define AVUTIL_AES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_aes AES
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_aes_size;
|
||||
|
||||
struct AVAES;
|
||||
|
||||
/**
|
||||
* Allocate an AVAES context.
|
||||
*/
|
||||
struct AVAES *av_aes_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVAES context.
|
||||
* @param key_bits 128, 192 or 256
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
* @param count number of 16 byte blocks
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AES_H */
|
||||
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Macro definitions for various function/variable attributes
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ATTRIBUTES_H
|
||||
#define AVUTIL_ATTRIBUTES_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
|
||||
#else
|
||||
# define AV_GCC_VERSION_AT_LEAST(x,y) 0
|
||||
#endif
|
||||
|
||||
#ifndef av_always_inline
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_always_inline __attribute__((always_inline)) inline
|
||||
#elif defined(_MSC_VER)
|
||||
# define av_always_inline __forceinline
|
||||
#else
|
||||
# define av_always_inline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_extern_inline
|
||||
#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
|
||||
# define av_extern_inline extern inline
|
||||
#else
|
||||
# define av_extern_inline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_noinline __attribute__((noinline))
|
||||
#else
|
||||
# define av_noinline
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_pure __attribute__((pure))
|
||||
#else
|
||||
# define av_pure
|
||||
#endif
|
||||
|
||||
#ifndef av_restrict
|
||||
#define av_restrict restrict
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(2,6)
|
||||
# define av_const __attribute__((const))
|
||||
#else
|
||||
# define av_const
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
# define av_cold __attribute__((cold))
|
||||
#else
|
||||
# define av_cold
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,1)
|
||||
# define av_flatten __attribute__((flatten))
|
||||
#else
|
||||
# define av_flatten
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define attribute_deprecated __attribute__((deprecated))
|
||||
#else
|
||||
# define attribute_deprecated
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Disable warnings about deprecated features
|
||||
* This is useful for sections of code kept for backward compatibility and
|
||||
* scheduled for removal.
|
||||
*/
|
||||
#ifndef AV_NOWARN_DEPRECATED
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,6)
|
||||
# define AV_NOWARN_DEPRECATED(code) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
|
||||
code \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#else
|
||||
# define AV_NOWARN_DEPRECATED(code) code
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define av_unused __attribute__((unused))
|
||||
#else
|
||||
# define av_unused
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Mark a variable as used and prevent the compiler from optimizing it
|
||||
* away. This is useful for variables accessed only from inline
|
||||
* assembler without the compiler being aware.
|
||||
*/
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_used __attribute__((used))
|
||||
#else
|
||||
# define av_used
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,3)
|
||||
# define av_alias __attribute__((may_alias))
|
||||
#else
|
||||
# define av_alias
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
|
||||
# define av_uninit(x) x=x
|
||||
#else
|
||||
# define av_uninit(x) x
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define av_builtin_constant_p __builtin_constant_p
|
||||
# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
|
||||
#else
|
||||
# define av_builtin_constant_p(x) 0
|
||||
# define av_printf_format(fmtpos, attrpos)
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(2,5)
|
||||
# define av_noreturn __attribute__((noreturn))
|
||||
#else
|
||||
# define av_noreturn
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_ATTRIBUTES_H */
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Audio FIFO
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav 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.
|
||||
*
|
||||
* Libav 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 Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Audio FIFO Buffer
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AUDIO_FIFO_H
|
||||
#define AVUTIL_AUDIO_FIFO_H
|
||||
|
||||
#include "avutil.h"
|
||||
#include "fifo.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Context for an Audio FIFO Buffer.
|
||||
*
|
||||
* - Operates at the sample level rather than the byte level.
|
||||
* - Supports multiple channels with either planar or packed sample format.
|
||||
* - Automatic reallocation when writing to a full buffer.
|
||||
*/
|
||||
typedef struct AVAudioFifo AVAudioFifo;
|
||||
|
||||
/**
|
||||
* Free an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to free
|
||||
*/
|
||||
void av_audio_fifo_free(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Allocate an AVAudioFifo.
|
||||
*
|
||||
* @param sample_fmt sample format
|
||||
* @param channels number of channels
|
||||
* @param nb_samples initial allocation size, in samples
|
||||
* @return newly allocated AVAudioFifo, or NULL on error
|
||||
*/
|
||||
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
|
||||
int nb_samples);
|
||||
|
||||
/**
|
||||
* Reallocate an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to reallocate
|
||||
* @param nb_samples new allocation size, in samples
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Write data to an AVAudioFifo.
|
||||
*
|
||||
* The AVAudioFifo will be reallocated automatically if the available space
|
||||
* is less than nb_samples.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to write to
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to write
|
||||
* @return number of samples actually written, or negative AVERROR
|
||||
* code on failure.
|
||||
*/
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Read data from an AVAudioFifo.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to read from
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to read
|
||||
* @return number of samples actually read, or negative AVERROR code
|
||||
* on failure.
|
||||
*/
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Drain data from an AVAudioFifo.
|
||||
*
|
||||
* Removes the data without reading it.
|
||||
*
|
||||
* @param af AVAudioFifo to drain
|
||||
* @param nb_samples number of samples to drain
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Reset the AVAudioFifo buffer.
|
||||
*
|
||||
* This empties all data in the buffer.
|
||||
*
|
||||
* @param af AVAudioFifo to reset
|
||||
*/
|
||||
void av_audio_fifo_reset(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for reading.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for reading
|
||||
*/
|
||||
int av_audio_fifo_size(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for writing.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for writing
|
||||
*/
|
||||
int av_audio_fifo_space(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AUDIO_FIFO_H */
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#if FF_API_AUDIOCONVERT
|
||||
#include "channel_layout.h"
|
||||
#endif
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* simple assert() macros that are a bit more flexible than ISO C assert().
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVASSERT_H
|
||||
#define AVUTIL_AVASSERT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "avutil.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
* assert() equivalent, that is always enabled.
|
||||
*/
|
||||
#define av_assert0(cond) do { \
|
||||
if (!(cond)) { \
|
||||
av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
|
||||
AV_STRINGIFY(cond), __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* assert() equivalent, that does not lie in speed critical code.
|
||||
* These asserts() thus can be enabled without fearing speedloss.
|
||||
*/
|
||||
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
|
||||
#define av_assert1(cond) av_assert0(cond)
|
||||
#else
|
||||
#define av_assert1(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* assert() equivalent, that does lie in speed critical code.
|
||||
*/
|
||||
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
|
||||
#define av_assert2(cond) av_assert0(cond)
|
||||
#else
|
||||
#define av_assert2(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_AVASSERT_H */
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Generated by ffconf */
|
||||
#ifndef AVUTIL_AVCONFIG_H
|
||||
#define AVUTIL_AVCONFIG_H
|
||||
#define AV_HAVE_BIGENDIAN 0
|
||||
#define AV_HAVE_FAST_UNALIGNED 1
|
||||
#define AV_HAVE_INCOMPATIBLE_FORK_ABI 0
|
||||
#endif /* AVUTIL_AVCONFIG_H */
|
||||
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Mans Rullgard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVSTRING_H
|
||||
#define AVUTIL_AVSTRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_string
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
|
||||
* the address of the first character in str after the prefix.
|
||||
*
|
||||
* @param str input string
|
||||
* @param pfx prefix to test
|
||||
* @param ptr updated if the prefix is matched inside str
|
||||
* @return non-zero if the prefix matches, zero otherwise
|
||||
*/
|
||||
int av_strstart(const char *str, const char *pfx, const char **ptr);
|
||||
|
||||
/**
|
||||
* Return non-zero if pfx is a prefix of str independent of case. If
|
||||
* it is, *ptr is set to the address of the first character in str
|
||||
* after the prefix.
|
||||
*
|
||||
* @param str input string
|
||||
* @param pfx prefix to test
|
||||
* @param ptr updated if the prefix is matched inside str
|
||||
* @return non-zero if the prefix matches, zero otherwise
|
||||
*/
|
||||
int av_stristart(const char *str, const char *pfx, const char **ptr);
|
||||
|
||||
/**
|
||||
* Locate the first case-independent occurrence in the string haystack
|
||||
* of the string needle. A zero-length string needle is considered to
|
||||
* match at the start of haystack.
|
||||
*
|
||||
* This function is a case-insensitive version of the standard strstr().
|
||||
*
|
||||
* @param haystack string to search in
|
||||
* @param needle string to search for
|
||||
* @return pointer to the located match within haystack
|
||||
* or a null pointer if no match
|
||||
*/
|
||||
char *av_stristr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* Copy the string src to dst, but no more than size - 1 bytes, and
|
||||
* null-terminate dst.
|
||||
*
|
||||
* This function is the same as BSD strlcpy().
|
||||
*
|
||||
* @param dst destination buffer
|
||||
* @param src source string
|
||||
* @param size size of destination buffer
|
||||
* @return the length of src
|
||||
*
|
||||
* @warning since the return value is the length of src, src absolutely
|
||||
* _must_ be a properly 0-terminated string, otherwise this will read beyond
|
||||
* the end of the buffer and possibly crash.
|
||||
*/
|
||||
size_t av_strlcpy(char *dst, const char *src, size_t size);
|
||||
|
||||
/**
|
||||
* Append the string src to the string dst, but to a total length of
|
||||
* no more than size - 1 bytes, and null-terminate dst.
|
||||
*
|
||||
* This function is similar to BSD strlcat(), but differs when
|
||||
* size <= strlen(dst).
|
||||
*
|
||||
* @param dst destination buffer
|
||||
* @param src source string
|
||||
* @param size size of destination buffer
|
||||
* @return the total length of src and dst
|
||||
*
|
||||
* @warning since the return value use the length of src and dst, these
|
||||
* absolutely _must_ be a properly 0-terminated strings, otherwise this
|
||||
* will read beyond the end of the buffer and possibly crash.
|
||||
*/
|
||||
size_t av_strlcat(char *dst, const char *src, size_t size);
|
||||
|
||||
/**
|
||||
* Append output to a string, according to a format. Never write out of
|
||||
* the destination buffer, and always put a terminating 0 within
|
||||
* the buffer.
|
||||
* @param dst destination buffer (string to which the output is
|
||||
* appended)
|
||||
* @param size total size of the destination buffer
|
||||
* @param fmt printf-compatible format string, specifying how the
|
||||
* following parameters are used
|
||||
* @return the length of the string that would have been generated
|
||||
* if enough space had been available
|
||||
*/
|
||||
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
|
||||
|
||||
/**
|
||||
* Print arguments following specified format into a large enough auto
|
||||
* allocated buffer. It is similar to GNU asprintf().
|
||||
* @param fmt printf-compatible format string, specifying how the
|
||||
* following parameters are used.
|
||||
* @return the allocated string
|
||||
* @note You have to free the string yourself with av_free().
|
||||
*/
|
||||
char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
|
||||
|
||||
/**
|
||||
* Convert a number to a av_malloced string.
|
||||
*/
|
||||
char *av_d2str(double d);
|
||||
|
||||
/**
|
||||
* Unescape the given string until a non escaped terminating char,
|
||||
* and return the token corresponding to the unescaped string.
|
||||
*
|
||||
* The normal \ and ' escaping is supported. Leading and trailing
|
||||
* whitespaces are removed, unless they are escaped with '\' or are
|
||||
* enclosed between ''.
|
||||
*
|
||||
* @param buf the buffer to parse, buf will be updated to point to the
|
||||
* terminating char
|
||||
* @param term a 0-terminated list of terminating chars
|
||||
* @return the malloced unescaped string, which must be av_freed by
|
||||
* the user, NULL in case of allocation failure
|
||||
*/
|
||||
char *av_get_token(const char **buf, const char *term);
|
||||
|
||||
/**
|
||||
* Split the string into several tokens which can be accessed by
|
||||
* successive calls to av_strtok().
|
||||
*
|
||||
* A token is defined as a sequence of characters not belonging to the
|
||||
* set specified in delim.
|
||||
*
|
||||
* On the first call to av_strtok(), s should point to the string to
|
||||
* parse, and the value of saveptr is ignored. In subsequent calls, s
|
||||
* should be NULL, and saveptr should be unchanged since the previous
|
||||
* call.
|
||||
*
|
||||
* This function is similar to strtok_r() defined in POSIX.1.
|
||||
*
|
||||
* @param s the string to parse, may be NULL
|
||||
* @param delim 0-terminated list of token delimiters, must be non-NULL
|
||||
* @param saveptr user-provided pointer which points to stored
|
||||
* information necessary for av_strtok() to continue scanning the same
|
||||
* string. saveptr is updated to point to the next character after the
|
||||
* first delimiter found, or to NULL if the string was terminated
|
||||
* @return the found token, or NULL when no token is found
|
||||
*/
|
||||
char *av_strtok(char *s, const char *delim, char **saveptr);
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII characters to uppercase.
|
||||
*/
|
||||
static inline int av_toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII characters to lowercase.
|
||||
*/
|
||||
static inline int av_tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent case-insensitive compare.
|
||||
* @note This means only ASCII-range characters are case-insensitive
|
||||
*/
|
||||
int av_strcasecmp(const char *a, const char *b);
|
||||
|
||||
/**
|
||||
* Locale-independent case-insensitive compare.
|
||||
* @note This means only ASCII-range characters are case-insensitive
|
||||
*/
|
||||
int av_strncasecmp(const char *a, const char *b, size_t n);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AVSTRING_H */
|
||||
@@ -1,260 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVUTIL_H
|
||||
#define AVUTIL_AVUTIL_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* external API header
|
||||
*/
|
||||
|
||||
/**
|
||||
* @mainpage
|
||||
*
|
||||
* @section ffmpeg_intro Introduction
|
||||
*
|
||||
* This document describes the usage of the different libraries
|
||||
* provided by FFmpeg.
|
||||
*
|
||||
* @li @ref libavc "libavcodec" encoding/decoding library
|
||||
* @li @ref lavfi "libavfilter" graph based frame editing library
|
||||
* @li @ref libavf "libavformat" I/O and muxing/demuxing library
|
||||
* @li @ref lavd "libavdevice" special devices muxing/demuxing library
|
||||
* @li @ref lavu "libavutil" common utility library
|
||||
* @li @ref lswr "libswresample" audio resampling, format conversion and mixing
|
||||
* @li @ref lpp "libpostproc" post processing library
|
||||
* @li @ref lsws "libswscale" color conversion and scaling library
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavu Common utility functions
|
||||
*
|
||||
* @brief
|
||||
* libavutil contains the code shared across all the other FFmpeg
|
||||
* libraries
|
||||
*
|
||||
* @note In order to use the functions provided by avutil you must include
|
||||
* the specific header.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_crypto Crypto and Hashing
|
||||
*
|
||||
* @{
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_math Maths
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_string String Manipulation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_mem Memory Management
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_data Data Structures
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_audio Audio related
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_error Error Codes
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_misc Other
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_internal Internal
|
||||
*
|
||||
* Not exported functions, for internal usage only
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_ver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the LIBAVUTIL_VERSION_INT constant.
|
||||
*/
|
||||
unsigned avutil_version(void);
|
||||
|
||||
/**
|
||||
* Return the libavutil build-time configuration.
|
||||
*/
|
||||
const char *avutil_configuration(void);
|
||||
|
||||
/**
|
||||
* Return the libavutil license.
|
||||
*/
|
||||
const char *avutil_license(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_media Media Type
|
||||
* @brief Media Type
|
||||
*/
|
||||
|
||||
enum AVMediaType {
|
||||
AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous
|
||||
AVMEDIA_TYPE_SUBTITLE,
|
||||
AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse
|
||||
AVMEDIA_TYPE_NB
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a string describing the media_type enum, NULL if media_type
|
||||
* is unknown.
|
||||
*/
|
||||
const char *av_get_media_type_string(enum AVMediaType media_type);
|
||||
|
||||
/**
|
||||
* @defgroup lavu_const Constants
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_enc Encoding specific
|
||||
*
|
||||
* @note those definition should move to avcodec
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_LAMBDA_SHIFT 7
|
||||
#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
|
||||
#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
|
||||
#define FF_LAMBDA_MAX (256*128-1)
|
||||
|
||||
#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @defgroup lavu_time Timestamp specific
|
||||
*
|
||||
* FFmpeg internal timebase and timestamp definitions
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Undefined timestamp value
|
||||
*
|
||||
* Usually reported by demuxer that work on containers that do not provide
|
||||
* either pts or dts.
|
||||
*/
|
||||
|
||||
#define AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
|
||||
|
||||
/**
|
||||
* Internal time base represented as integer
|
||||
*/
|
||||
|
||||
#define AV_TIME_BASE 1000000
|
||||
|
||||
/**
|
||||
* Internal time base represented as fractional value
|
||||
*/
|
||||
|
||||
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @defgroup lavu_picture Image related
|
||||
*
|
||||
* AVPicture types, pixel formats and basic image planes manipulation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVPictureType {
|
||||
AV_PICTURE_TYPE_NONE = 0, ///< Undefined
|
||||
AV_PICTURE_TYPE_I, ///< Intra
|
||||
AV_PICTURE_TYPE_P, ///< Predicted
|
||||
AV_PICTURE_TYPE_B, ///< Bi-dir predicted
|
||||
AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG4
|
||||
AV_PICTURE_TYPE_SI, ///< Switching Intra
|
||||
AV_PICTURE_TYPE_SP, ///< Switching Predicted
|
||||
AV_PICTURE_TYPE_BI, ///< BI type
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a single letter to describe the given picture type
|
||||
* pict_type.
|
||||
*
|
||||
* @param[in] pict_type the picture type @return a single character
|
||||
* representing the picture type, '?' if pict_type is unknown
|
||||
*/
|
||||
char av_get_picture_type_char(enum AVPictureType pict_type);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "version.h"
|
||||
#include "mathematics.h"
|
||||
#include "rational.h"
|
||||
#include "intfloat_readwrite.h"
|
||||
#include "log.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
/**
|
||||
* Return x default pointer in case p is NULL.
|
||||
*/
|
||||
static inline void *av_x_if_null(const void *p, const void *x)
|
||||
{
|
||||
return (void *)(intptr_t)(p ? p : x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AVUTIL_H */
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com)
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BASE64_H
|
||||
#define AVUTIL_BASE64_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_base64 Base64
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Decode a base64-encoded string.
|
||||
*
|
||||
* @param out buffer for decoded data
|
||||
* @param in null-terminated input string
|
||||
* @param out_size size in bytes of the out buffer, must be at
|
||||
* least 3/4 of the length of in
|
||||
* @return number of bytes written, or a negative value in case of
|
||||
* invalid input
|
||||
*/
|
||||
int av_base64_decode(uint8_t *out, const char *in, int out_size);
|
||||
|
||||
/**
|
||||
* Encode data to base64 and null-terminate.
|
||||
*
|
||||
* @param out buffer for encoded data
|
||||
* @param out_size size in bytes of the output buffer, must be at
|
||||
* least AV_BASE64_SIZE(in_size)
|
||||
* @param in_size size in bytes of the 'in' buffer
|
||||
* @return 'out' or NULL in case of error
|
||||
*/
|
||||
char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size);
|
||||
|
||||
/**
|
||||
* Calculate the output size needed to base64-encode x bytes.
|
||||
*/
|
||||
#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BASE64_H */
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Blowfish algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BLOWFISH_H
|
||||
#define AVUTIL_BLOWFISH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_blowfish Blowfish
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_BF_ROUNDS 16
|
||||
|
||||
typedef struct AVBlowfish {
|
||||
uint32_t p[AV_BF_ROUNDS + 2];
|
||||
uint32_t s[4][256];
|
||||
} AVBlowfish;
|
||||
|
||||
/**
|
||||
* Initialize an AVBlowfish context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param key a key
|
||||
* @param key_len length of the key
|
||||
*/
|
||||
void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param xl left four bytes halves of input to be encrypted
|
||||
* @param xr right four bytes halves of input to be encrypted
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
|
||||
int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BLOWFISH_H */
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Nicolas George
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BPRINT_H
|
||||
#define AVUTIL_BPRINT_H
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* Define a structure with extra padding to a fixed size
|
||||
* This helps ensuring binary compatibility with future versions.
|
||||
*/
|
||||
#define FF_PAD_STRUCTURE(size, ...) \
|
||||
__VA_ARGS__ \
|
||||
char reserved_padding[size - sizeof(struct { __VA_ARGS__ })];
|
||||
|
||||
/**
|
||||
* Buffer to print data progressively
|
||||
*
|
||||
* The string buffer grows as necessary and is always 0-terminated.
|
||||
* The content of the string is never accessed, and thus is
|
||||
* encoding-agnostic and can even hold binary data.
|
||||
*
|
||||
* Small buffers are kept in the structure itself, and thus require no
|
||||
* memory allocation at all (unless the contents of the buffer is needed
|
||||
* after the structure goes out of scope). This is almost as lightweight as
|
||||
* declaring a local "char buf[512]".
|
||||
*
|
||||
* The length of the string can go beyond the allocated size: the buffer is
|
||||
* then truncated, but the functions still keep account of the actual total
|
||||
* length.
|
||||
*
|
||||
* In other words, buf->len can be greater than buf->size and records the
|
||||
* total length of what would have been to the buffer if there had been
|
||||
* enough memory.
|
||||
*
|
||||
* Append operations do not need to be tested for failure: if a memory
|
||||
* allocation fails, data stop being appended to the buffer, but the length
|
||||
* is still updated. This situation can be tested with
|
||||
* av_bprint_is_complete().
|
||||
*
|
||||
* The size_max field determines several possible behaviours:
|
||||
*
|
||||
* size_max = -1 (= UINT_MAX) or any large value will let the buffer be
|
||||
* reallocated as necessary, with an amortized linear cost.
|
||||
*
|
||||
* size_max = 0 prevents writing anything to the buffer: only the total
|
||||
* length is computed. The write operations can then possibly be repeated in
|
||||
* a buffer with exactly the necessary size
|
||||
* (using size_init = size_max = len + 1).
|
||||
*
|
||||
* size_max = 1 is automatically replaced by the exact size available in the
|
||||
* structure itself, thus ensuring no dynamic memory allocation. The
|
||||
* internal buffer is large enough to hold a reasonable paragraph of text,
|
||||
* such as the current paragraph.
|
||||
*/
|
||||
typedef struct AVBPrint {
|
||||
FF_PAD_STRUCTURE(1024,
|
||||
char *str; /** string so far */
|
||||
unsigned len; /** length so far */
|
||||
unsigned size; /** allocated memory */
|
||||
unsigned size_max; /** maximum allocated memory */
|
||||
char reserved_internal_buffer[1];
|
||||
)
|
||||
} AVBPrint;
|
||||
|
||||
/**
|
||||
* Convenience macros for special values for av_bprint_init() size_max
|
||||
* parameter.
|
||||
*/
|
||||
#define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
|
||||
#define AV_BPRINT_SIZE_AUTOMATIC 1
|
||||
#define AV_BPRINT_SIZE_COUNT_ONLY 0
|
||||
|
||||
/**
|
||||
* Init a print buffer.
|
||||
*
|
||||
* @param buf buffer to init
|
||||
* @param size_init initial size (including the final 0)
|
||||
* @param size_max maximum size;
|
||||
* 0 means do not write anything, just count the length;
|
||||
* 1 is replaced by the maximum value for automatic storage;
|
||||
* any large value means that the internal buffer will be
|
||||
* reallocated as needed up to that limit; -1 is converted to
|
||||
* UINT_MAX, the largest limit possible.
|
||||
* Check also AV_BPRINT_SIZE_* macros.
|
||||
*/
|
||||
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
|
||||
|
||||
/**
|
||||
* Init a print buffer using a pre-existing buffer.
|
||||
*
|
||||
* The buffer will not be reallocated.
|
||||
*
|
||||
* @param buf buffer structure to init
|
||||
* @param buffer byte buffer to use for the string data
|
||||
* @param size size of buffer
|
||||
*/
|
||||
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
|
||||
|
||||
/**
|
||||
* Append a formatted string to a print buffer.
|
||||
*/
|
||||
void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
|
||||
|
||||
/**
|
||||
* Append char c n times to a print buffer.
|
||||
*/
|
||||
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
|
||||
|
||||
struct tm;
|
||||
/**
|
||||
* Append a formatted date and time to a print buffer.
|
||||
*
|
||||
* param buf bprint buffer to use
|
||||
* param fmt date and time format string, see strftime()
|
||||
* param tm broken-down time structure to translate
|
||||
*
|
||||
* @note due to poor design of the standard strftime function, it may
|
||||
* produce poor results if the format string expands to a very long text and
|
||||
* the bprint buffer is near the limit stated by the size_max option.
|
||||
*/
|
||||
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
|
||||
|
||||
/**
|
||||
* Allocate bytes in the buffer for external use.
|
||||
*
|
||||
* @param[in] buf buffer structure
|
||||
* @param[in] size required size
|
||||
* @param[out] mem pointer to the memory area
|
||||
* @param[out] actual_size size of the memory area after allocation;
|
||||
* can be larger or smaller than size
|
||||
*/
|
||||
void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
|
||||
unsigned char **mem, unsigned *actual_size);
|
||||
|
||||
/**
|
||||
* Reset the string to "" but keep internal allocated data.
|
||||
*/
|
||||
void av_bprint_clear(AVBPrint *buf);
|
||||
|
||||
/**
|
||||
* Test if the print buffer is complete (not truncated).
|
||||
*
|
||||
* It may have been truncated due to a memory allocation failure
|
||||
* or the size_max limit (compare size and size_max if necessary).
|
||||
*/
|
||||
static inline int av_bprint_is_complete(AVBPrint *buf)
|
||||
{
|
||||
return buf->len < buf->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize a print buffer.
|
||||
*
|
||||
* The print buffer can no longer be used afterwards,
|
||||
* but the len and size fields are still valid.
|
||||
*
|
||||
* @arg[out] ret_str if not NULL, used to return a permanent copy of the
|
||||
* buffer contents, or NULL if memory allocation fails;
|
||||
* if NULL, the buffer is discarded and freed
|
||||
* @return 0 for success or error code (probably AVERROR(ENOMEM))
|
||||
*/
|
||||
int av_bprint_finalize(AVBPrint *buf, char **ret_str);
|
||||
|
||||
#endif /* AVUTIL_BPRINT_H */
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* byte swapping routines
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BSWAP_H
|
||||
#define AVUTIL_BSWAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/avconfig.h"
|
||||
#include "attributes.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/bswap.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/bswap.h"
|
||||
#elif ARCH_BFIN
|
||||
# include "bfin/bswap.h"
|
||||
#elif ARCH_SH4
|
||||
# include "sh4/bswap.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/bswap.h"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
|
||||
#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
|
||||
#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))
|
||||
|
||||
#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)
|
||||
|
||||
#ifndef av_bswap16
|
||||
static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
|
||||
{
|
||||
x= (x>>8) | (x<<8);
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap32
|
||||
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
|
||||
{
|
||||
return AV_BSWAP32C(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap64
|
||||
static inline uint64_t av_const av_bswap64(uint64_t x)
|
||||
{
|
||||
return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
// be2ne ... big-endian to native-endian
|
||||
// le2ne ... little-endian to native-endian
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
#define av_be2ne16(x) (x)
|
||||
#define av_be2ne32(x) (x)
|
||||
#define av_be2ne64(x) (x)
|
||||
#define av_le2ne16(x) av_bswap16(x)
|
||||
#define av_le2ne32(x) av_bswap32(x)
|
||||
#define av_le2ne64(x) av_bswap64(x)
|
||||
#define AV_BE2NEC(s, x) (x)
|
||||
#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)
|
||||
#else
|
||||
#define av_be2ne16(x) av_bswap16(x)
|
||||
#define av_be2ne32(x) av_bswap32(x)
|
||||
#define av_be2ne64(x) av_bswap64(x)
|
||||
#define av_le2ne16(x) (x)
|
||||
#define av_le2ne32(x) (x)
|
||||
#define av_le2ne64(x) (x)
|
||||
#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)
|
||||
#define AV_LE2NEC(s, x) (x)
|
||||
#endif
|
||||
|
||||
#define AV_BE2NE16C(x) AV_BE2NEC(16, x)
|
||||
#define AV_BE2NE32C(x) AV_BE2NEC(32, x)
|
||||
#define AV_BE2NE64C(x) AV_BE2NEC(64, x)
|
||||
#define AV_LE2NE16C(x) AV_LE2NEC(16, x)
|
||||
#define AV_LE2NE32C(x) AV_LE2NEC(32, x)
|
||||
#define AV_LE2NE64C(x) AV_LE2NEC(64, x)
|
||||
|
||||
#endif /* AVUTIL_BSWAP_H */
|
||||
@@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (c) 2008 Peter Ross
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CHANNEL_LAYOUT_H
|
||||
#define AVUTIL_CHANNEL_LAYOUT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio channel layout utility functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup channel_masks Audio channel masks
|
||||
*
|
||||
* A channel layout is a 64-bits integer with a bit set for every channel.
|
||||
* The number of bits set must be equal to the number of channels.
|
||||
* The value 0 means that the channel layout is not known.
|
||||
* @note this data structure is not powerful enough to handle channels
|
||||
* combinations that have the same channel multiple times, such as
|
||||
* dual-mono.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define AV_CH_FRONT_LEFT 0x00000001
|
||||
#define AV_CH_FRONT_RIGHT 0x00000002
|
||||
#define AV_CH_FRONT_CENTER 0x00000004
|
||||
#define AV_CH_LOW_FREQUENCY 0x00000008
|
||||
#define AV_CH_BACK_LEFT 0x00000010
|
||||
#define AV_CH_BACK_RIGHT 0x00000020
|
||||
#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040
|
||||
#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080
|
||||
#define AV_CH_BACK_CENTER 0x00000100
|
||||
#define AV_CH_SIDE_LEFT 0x00000200
|
||||
#define AV_CH_SIDE_RIGHT 0x00000400
|
||||
#define AV_CH_TOP_CENTER 0x00000800
|
||||
#define AV_CH_TOP_FRONT_LEFT 0x00001000
|
||||
#define AV_CH_TOP_FRONT_CENTER 0x00002000
|
||||
#define AV_CH_TOP_FRONT_RIGHT 0x00004000
|
||||
#define AV_CH_TOP_BACK_LEFT 0x00008000
|
||||
#define AV_CH_TOP_BACK_CENTER 0x00010000
|
||||
#define AV_CH_TOP_BACK_RIGHT 0x00020000
|
||||
#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
|
||||
#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT.
|
||||
#define AV_CH_WIDE_LEFT 0x0000000080000000ULL
|
||||
#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL
|
||||
#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL
|
||||
#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL
|
||||
#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL
|
||||
|
||||
/** Channel mask value used for AVCodecContext.request_channel_layout
|
||||
to indicate that the user requests the channel order of the decoder output
|
||||
to be the native codec channel order. */
|
||||
#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @defgroup channel_mask_c Audio channel convenience macros
|
||||
* @{
|
||||
* */
|
||||
#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)
|
||||
#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
|
||||
#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
||||
#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
|
||||
|
||||
enum AVMatrixEncoding {
|
||||
AV_MATRIX_ENCODING_NONE,
|
||||
AV_MATRIX_ENCODING_DOLBY,
|
||||
AV_MATRIX_ENCODING_DPLII,
|
||||
AV_MATRIX_ENCODING_NB
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a channel layout id that matches name, or 0 if no match is found.
|
||||
*
|
||||
* name can be one or several of the following notations,
|
||||
* separated by '+' or '|':
|
||||
* - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,
|
||||
* 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);
|
||||
* - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,
|
||||
* SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);
|
||||
* - a number of channels, in decimal, optionally followed by 'c', yielding
|
||||
* the default channel layout for that number of channels (@see
|
||||
* av_get_default_channel_layout);
|
||||
* - a channel layout mask, in hexadecimal starting with "0x" (see the
|
||||
* AV_CH_* macros).
|
||||
*
|
||||
* Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7"
|
||||
*/
|
||||
uint64_t av_get_channel_layout(const char *name);
|
||||
|
||||
/**
|
||||
* Return a description of a channel layout.
|
||||
* If nb_channels is <= 0, it is guessed from the channel_layout.
|
||||
*
|
||||
* @param buf put here the string containing the channel layout
|
||||
* @param buf_size size in bytes of the buffer
|
||||
*/
|
||||
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);
|
||||
|
||||
struct AVBPrint;
|
||||
/**
|
||||
* Append a description of a channel layout to a bprint buffer.
|
||||
*/
|
||||
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return the number of channels in the channel layout.
|
||||
*/
|
||||
int av_get_channel_layout_nb_channels(uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return default channel layout for a given number of channels.
|
||||
*/
|
||||
int64_t av_get_default_channel_layout(int nb_channels);
|
||||
|
||||
/**
|
||||
* Get the index of a channel in channel_layout.
|
||||
*
|
||||
* @param channel a channel layout describing exactly one channel which must be
|
||||
* present in channel_layout.
|
||||
*
|
||||
* @return index of channel in channel_layout on success, a negative AVERROR
|
||||
* on error.
|
||||
*/
|
||||
int av_get_channel_layout_channel_index(uint64_t channel_layout,
|
||||
uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the channel with the given index in channel_layout.
|
||||
*/
|
||||
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
|
||||
|
||||
/**
|
||||
* Get the name of a given channel.
|
||||
*
|
||||
* @return channel name on success, NULL on error.
|
||||
*/
|
||||
const char *av_get_channel_name(uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the description of a given channel.
|
||||
*
|
||||
* @param channel a channel layout with a single channel
|
||||
* @return channel description on success, NULL on error
|
||||
*/
|
||||
const char *av_get_channel_description(uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the value and name of a standard channel layout.
|
||||
*
|
||||
* @param[in] index index in an internal list, starting at 0
|
||||
* @param[out] layout channel layout mask
|
||||
* @param[out] name name of the layout
|
||||
* @return 0 if the layout exists,
|
||||
* <0 if index is beyond the limits
|
||||
*/
|
||||
int av_get_standard_channel_layout(unsigned index, uint64_t *layout,
|
||||
const char **name);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_CHANNEL_LAYOUT_H */
|
||||
@@ -1,428 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* common internal and external API header
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_COMMON_H
|
||||
#define AVUTIL_COMMON_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
#include "libavutil/avconfig.h"
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_NE(be, le) (be)
|
||||
#else
|
||||
# define AV_NE(be, le) (le)
|
||||
#endif
|
||||
|
||||
//rounded division & shift
|
||||
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
|
||||
/* assume b>0 */
|
||||
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
|
||||
#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
|
||||
#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
|
||||
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
|
||||
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
|
||||
|
||||
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
|
||||
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
|
||||
|
||||
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
|
||||
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
|
||||
|
||||
/* misc math functions */
|
||||
|
||||
/**
|
||||
* Reverse the order of the bits of an 8-bits unsigned integer.
|
||||
*/
|
||||
#if FF_API_AV_REVERSE
|
||||
extern attribute_deprecated const uint8_t av_reverse[256];
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
# include "intmath.h"
|
||||
#endif
|
||||
|
||||
/* Pull in unguarded fallback defines at the end of this file. */
|
||||
#include "common.h"
|
||||
|
||||
#ifndef av_log2
|
||||
av_const int av_log2(unsigned v);
|
||||
#endif
|
||||
|
||||
#ifndef av_log2_16bit
|
||||
av_const int av_log2_16bit(unsigned v);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
|
||||
{
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed 64bit integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
|
||||
{
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the 0-255 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
||||
{
|
||||
if (a&(~0xFF)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the -128,127 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
||||
{
|
||||
if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the 0-65535 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
||||
{
|
||||
if (a&(~0xFFFF)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the -32768,32767 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
||||
{
|
||||
if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
{
|
||||
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
|
||||
else return (int32_t)a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer to an unsigned power of two range.
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
||||
{
|
||||
if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add two signed 32-bit values with saturation.
|
||||
*
|
||||
* @param a one value
|
||||
* @param b another value
|
||||
* @return sum with signed saturation
|
||||
*/
|
||||
static av_always_inline int av_sat_add32_c(int a, int b)
|
||||
{
|
||||
return av_clipl_int32((int64_t)a + b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a doubled value to another value with saturation at both stages.
|
||||
*
|
||||
* @param a first value
|
||||
* @param b value doubled and added to a
|
||||
* @return sum with signed saturation
|
||||
*/
|
||||
static av_always_inline int av_sat_dadd32_c(int a, int b)
|
||||
{
|
||||
return av_sat_add32(a, av_sat_add32(b, b));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a float value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
|
||||
{
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/** Compute ceil(log2(x)).
|
||||
* @param x value used to compute ceil(log2(x))
|
||||
* @return computed ceiling of log2(x)
|
||||
*/
|
||||
static av_always_inline av_const int av_ceil_log2_c(int x)
|
||||
{
|
||||
return av_log2((x - 1) << 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount_c(uint32_t x)
|
||||
{
|
||||
x -= (x >> 1) & 0x55555555;
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x += x >> 8;
|
||||
return (x + (x >> 16)) & 0x3F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount64_c(uint64_t x)
|
||||
{
|
||||
return av_popcount((uint32_t)x) + av_popcount(x >> 32);
|
||||
}
|
||||
|
||||
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
|
||||
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
|
||||
|
||||
/**
|
||||
* Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
*
|
||||
* @param val Output value, must be an lvalue of type uint32_t.
|
||||
* @param GET_BYTE Expression reading one byte from the input.
|
||||
* Evaluated up to 7 times (4 for the currently
|
||||
* assigned Unicode range). With a memory buffer
|
||||
* input, this could be *ptr++.
|
||||
* @param ERROR Expression to be evaluated on invalid input,
|
||||
* typically a goto statement.
|
||||
*/
|
||||
#define GET_UTF8(val, GET_BYTE, ERROR)\
|
||||
val= GET_BYTE;\
|
||||
{\
|
||||
uint32_t top = (val & 128) >> 1;\
|
||||
if ((val & 0xc0) == 0x80)\
|
||||
ERROR\
|
||||
while (val & top) {\
|
||||
int tmp= GET_BYTE - 128;\
|
||||
if(tmp>>6)\
|
||||
ERROR\
|
||||
val= (val<<6) + tmp;\
|
||||
top <<= 5;\
|
||||
}\
|
||||
val &= (top << 1) - 1;\
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
*
|
||||
* @param val Output value, must be an lvalue of type uint32_t.
|
||||
* @param GET_16BIT Expression returning two bytes of UTF-16 data converted
|
||||
* to native byte order. Evaluated one or two times.
|
||||
* @param ERROR Expression to be evaluated on invalid input,
|
||||
* typically a goto statement.
|
||||
*/
|
||||
#define GET_UTF16(val, GET_16BIT, ERROR)\
|
||||
val = GET_16BIT;\
|
||||
{\
|
||||
unsigned int hi = val - 0xD800;\
|
||||
if (hi < 0x800) {\
|
||||
val = GET_16BIT - 0xDC00;\
|
||||
if (val > 0x3FFU || hi > 0x3FFU)\
|
||||
ERROR\
|
||||
val += (hi<<10) + 0x10000;\
|
||||
}\
|
||||
}\
|
||||
|
||||
/**
|
||||
* @def PUT_UTF8(val, tmp, PUT_BYTE)
|
||||
* Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
|
||||
* val is given as a function it is executed only once.
|
||||
* @param tmp is a temporary variable and should be of type uint8_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_BYTE.
|
||||
* @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
|
||||
* It could be a function or a statement, and uses tmp as the input byte.
|
||||
* For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
|
||||
* executed up to 4 times for values in the valid UTF-8 range and up to
|
||||
* 7 times in the general case, depending on the length of the converted
|
||||
* Unicode character.
|
||||
*/
|
||||
#define PUT_UTF8(val, tmp, PUT_BYTE)\
|
||||
{\
|
||||
int bytes, shift;\
|
||||
uint32_t in = val;\
|
||||
if (in < 0x80) {\
|
||||
tmp = in;\
|
||||
PUT_BYTE\
|
||||
} else {\
|
||||
bytes = (av_log2(in) + 4) / 5;\
|
||||
shift = (bytes - 1) * 6;\
|
||||
tmp = (256 - (256 >> bytes)) | (in >> shift);\
|
||||
PUT_BYTE\
|
||||
while (shift >= 6) {\
|
||||
shift -= 6;\
|
||||
tmp = 0x80 | ((in >> shift) & 0x3f);\
|
||||
PUT_BYTE\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
/**
|
||||
* @def PUT_UTF16(val, tmp, PUT_16BIT)
|
||||
* Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
|
||||
* val is given as a function it is executed only once.
|
||||
* @param tmp is a temporary variable and should be of type uint16_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_16BIT.
|
||||
* @param PUT_16BIT writes the converted UTF-16 data to any proper destination
|
||||
* in desired endianness. It could be a function or a statement, and uses tmp
|
||||
* as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
|
||||
* PUT_BYTE will be executed 1 or 2 times depending on input character.
|
||||
*/
|
||||
#define PUT_UTF16(val, tmp, PUT_16BIT)\
|
||||
{\
|
||||
uint32_t in = val;\
|
||||
if (in < 0x10000) {\
|
||||
tmp = in;\
|
||||
PUT_16BIT\
|
||||
} else {\
|
||||
tmp = 0xD800 | ((in - 0x10000) >> 10);\
|
||||
PUT_16BIT\
|
||||
tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
|
||||
PUT_16BIT\
|
||||
}\
|
||||
}\
|
||||
|
||||
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "internal.h"
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#endif /* AVUTIL_COMMON_H */
|
||||
|
||||
/*
|
||||
* The following definitions are outside the multiple inclusion guard
|
||||
* to ensure they are immediately available in intmath.h.
|
||||
*/
|
||||
|
||||
#ifndef av_ceil_log2
|
||||
# define av_ceil_log2 av_ceil_log2_c
|
||||
#endif
|
||||
#ifndef av_clip
|
||||
# define av_clip av_clip_c
|
||||
#endif
|
||||
#ifndef av_clip64
|
||||
# define av_clip64 av_clip64_c
|
||||
#endif
|
||||
#ifndef av_clip_uint8
|
||||
# define av_clip_uint8 av_clip_uint8_c
|
||||
#endif
|
||||
#ifndef av_clip_int8
|
||||
# define av_clip_int8 av_clip_int8_c
|
||||
#endif
|
||||
#ifndef av_clip_uint16
|
||||
# define av_clip_uint16 av_clip_uint16_c
|
||||
#endif
|
||||
#ifndef av_clip_int16
|
||||
# define av_clip_int16 av_clip_int16_c
|
||||
#endif
|
||||
#ifndef av_clipl_int32
|
||||
# define av_clipl_int32 av_clipl_int32_c
|
||||
#endif
|
||||
#ifndef av_clip_uintp2
|
||||
# define av_clip_uintp2 av_clip_uintp2_c
|
||||
#endif
|
||||
#ifndef av_sat_add32
|
||||
# define av_sat_add32 av_sat_add32_c
|
||||
#endif
|
||||
#ifndef av_sat_dadd32
|
||||
# define av_sat_dadd32 av_sat_dadd32_c
|
||||
#endif
|
||||
#ifndef av_clipf
|
||||
# define av_clipf av_clipf_c
|
||||
#endif
|
||||
#ifndef av_popcount
|
||||
# define av_popcount av_popcount_c
|
||||
#endif
|
||||
#ifndef av_popcount64
|
||||
# define av_popcount64 av_popcount64_c
|
||||
#endif
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CPU_H
|
||||
#define AVUTIL_CPU_H
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
|
||||
|
||||
/* lower 16 bits - CPU features */
|
||||
#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX
|
||||
#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
|
||||
#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
|
||||
#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW
|
||||
#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions
|
||||
#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions
|
||||
#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster
|
||||
#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt
|
||||
#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions
|
||||
#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster
|
||||
#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions
|
||||
#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower
|
||||
#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
|
||||
#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
|
||||
#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
|
||||
#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions
|
||||
#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
|
||||
// #if LIBAVUTIL_VERSION_MAJOR <52
|
||||
#define AV_CPU_FLAG_CMOV 0x1001000 ///< supports cmov instruction
|
||||
// #else
|
||||
// #define AV_CPU_FLAG_CMOV 0x1000 ///< supports cmov instruction
|
||||
// #endif
|
||||
|
||||
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
|
||||
|
||||
#define AV_CPU_FLAG_ARMV5TE (1 << 0)
|
||||
#define AV_CPU_FLAG_ARMV6 (1 << 1)
|
||||
#define AV_CPU_FLAG_ARMV6T2 (1 << 2)
|
||||
#define AV_CPU_FLAG_VFP (1 << 3)
|
||||
#define AV_CPU_FLAG_VFPV3 (1 << 4)
|
||||
#define AV_CPU_FLAG_NEON (1 << 5)
|
||||
|
||||
/**
|
||||
* Return the flags which specify extensions supported by the CPU.
|
||||
* The returned value is affected by av_force_cpu_flags() if that was used
|
||||
* before. So av_get_cpu_flags() can easily be used in a application to
|
||||
* detect the enabled cpu flags.
|
||||
*/
|
||||
int av_get_cpu_flags(void);
|
||||
|
||||
/**
|
||||
* Disables cpu detection and forces the specified flags.
|
||||
* -1 is a special case that disables forcing of specific flags.
|
||||
*/
|
||||
void av_force_cpu_flags(int flags);
|
||||
|
||||
/**
|
||||
* Set a mask on flags returned by av_get_cpu_flags().
|
||||
* This function is mainly useful for testing.
|
||||
* Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible
|
||||
*
|
||||
* @warning this function is not thread safe.
|
||||
*/
|
||||
attribute_deprecated void av_set_cpu_flags_mask(int mask);
|
||||
|
||||
/**
|
||||
* Parse CPU flags from a string.
|
||||
*
|
||||
* The returned flags contain the specified flags as well as related unspecified flags.
|
||||
*
|
||||
* This function exists only for compatibility with libav.
|
||||
* Please use av_parse_cpu_caps() when possible.
|
||||
* @return a combination of AV_CPU_* flags, negative on error.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_parse_cpu_flags(const char *s);
|
||||
|
||||
/**
|
||||
* Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
|
||||
*
|
||||
* @return negative on error.
|
||||
*/
|
||||
int av_parse_cpu_caps(unsigned *flags, const char *s);
|
||||
|
||||
/* The following CPU-specific functions shall not be called directly. */
|
||||
int ff_get_cpu_flags_arm(void);
|
||||
int ff_get_cpu_flags_ppc(void);
|
||||
int ff_get_cpu_flags_x86(void);
|
||||
|
||||
#endif /* AVUTIL_CPU_H */
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CRC_H
|
||||
#define AVUTIL_CRC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "attributes.h"
|
||||
|
||||
typedef uint32_t AVCRC;
|
||||
|
||||
typedef enum {
|
||||
AV_CRC_8_ATM,
|
||||
AV_CRC_16_ANSI,
|
||||
AV_CRC_16_CCITT,
|
||||
AV_CRC_32_IEEE,
|
||||
AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
|
||||
AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
|
||||
}AVCRCId;
|
||||
|
||||
/**
|
||||
* Initialize a CRC table.
|
||||
* @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
|
||||
* @param le If 1, the lowest bit represents the coefficient for the highest
|
||||
* exponent of the corresponding polynomial (both for poly and
|
||||
* actual CRC).
|
||||
* If 0, you must swap the CRC parameter and the result of av_crc
|
||||
* if you need the standard representation (can be simplified in
|
||||
* most cases to e.g. bswap16):
|
||||
* av_bswap32(crc << (32-bits))
|
||||
* @param bits number of bits for the CRC
|
||||
* @param poly generator polynomial without the x**bits coefficient, in the
|
||||
* representation as specified by le
|
||||
* @param ctx_size size of ctx in bytes
|
||||
* @return <0 on failure
|
||||
*/
|
||||
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
|
||||
|
||||
/**
|
||||
* Get an initialized standard CRC table.
|
||||
* @param crc_id ID of a standard CRC
|
||||
* @return a pointer to the CRC table or NULL on failure
|
||||
*/
|
||||
const AVCRC *av_crc_get_table(AVCRCId crc_id);
|
||||
|
||||
/**
|
||||
* Calculate the CRC of a block.
|
||||
* @param crc CRC of previous blocks if any or initial value for CRC
|
||||
* @return CRC updated with the data from the given block
|
||||
*
|
||||
* @see av_crc_init() "le" parameter
|
||||
*/
|
||||
uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
|
||||
const uint8_t *buffer, size_t length) av_pure;
|
||||
|
||||
#endif /* AVUTIL_CRC_H */
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Public dictionary API.
|
||||
* @deprecated
|
||||
* AVDictionary is provided for compatibility with libav. It is both in
|
||||
* implementation as well as API inefficient. It does not scale and is
|
||||
* extremely slow with large dictionaries.
|
||||
* It is recommended that new code uses our tree container from tree.c/h
|
||||
* where applicable, which uses AVL trees to achieve O(log n) performance.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DICT_H
|
||||
#define AVUTIL_DICT_H
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_dict AVDictionary
|
||||
* @ingroup lavu_data
|
||||
*
|
||||
* @brief Simple key:value store
|
||||
*
|
||||
* @{
|
||||
* Dictionaries are used for storing key:value pairs. To create
|
||||
* an AVDictionary, simply pass an address of a NULL pointer to
|
||||
* av_dict_set(). NULL can be used as an empty dictionary wherever
|
||||
* a pointer to an AVDictionary is required.
|
||||
* Use av_dict_get() to retrieve an entry or iterate over all
|
||||
* entries and finally av_dict_free() to free the dictionary
|
||||
* and all its contents.
|
||||
*
|
||||
* @code
|
||||
* AVDictionary *d = NULL; // "create" an empty dictionary
|
||||
* av_dict_set(&d, "foo", "bar", 0); // add an entry
|
||||
*
|
||||
* char *k = av_strdup("key"); // if your strings are already allocated,
|
||||
* char *v = av_strdup("value"); // you can avoid copying them like this
|
||||
* av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
*
|
||||
* AVDictionaryEntry *t = NULL;
|
||||
* while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
|
||||
* <....> // iterate over all entries in d
|
||||
* }
|
||||
*
|
||||
* av_dict_free(&d);
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
|
||||
#define AV_DICT_MATCH_CASE 1
|
||||
#define AV_DICT_IGNORE_SUFFIX 2
|
||||
#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
|
||||
allocated with av_malloc() and children. */
|
||||
#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
|
||||
allocated with av_malloc() and chilren. */
|
||||
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
|
||||
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
||||
delimiter is added, the strings are simply concatenated. */
|
||||
|
||||
typedef struct AVDictionaryEntry {
|
||||
char *key;
|
||||
char *value;
|
||||
} AVDictionaryEntry;
|
||||
|
||||
typedef struct AVDictionary AVDictionary;
|
||||
|
||||
/**
|
||||
* Get a dictionary entry with matching key.
|
||||
*
|
||||
* @param prev Set to the previous matching element to find the next.
|
||||
* If set to NULL the first matching element is returned.
|
||||
* @param flags Allows case as well as suffix-insensitive comparisons.
|
||||
* @return Found entry or NULL, changing key or value leads to undefined behavior.
|
||||
*/
|
||||
AVDictionaryEntry *
|
||||
av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
|
||||
|
||||
/**
|
||||
* Get number of entries in dictionary.
|
||||
*
|
||||
* @param m dictionary
|
||||
* @return number of entries in dictionary
|
||||
*/
|
||||
int av_dict_count(const AVDictionary *m);
|
||||
|
||||
/**
|
||||
* Set the given entry in *pm, overwriting an existing entry.
|
||||
*
|
||||
* @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
|
||||
* a dictionary struct is allocated and put in *pm.
|
||||
* @param key entry key to add to *pm (will be av_strduped depending on flags)
|
||||
* @param value entry value to add to *pm (will be av_strduped depending on flags).
|
||||
* Passing a NULL value will cause an existing entry to be deleted.
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
|
||||
|
||||
/**
|
||||
* Copy entries from one AVDictionary struct into another.
|
||||
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
|
||||
* this function will allocate a struct for you and put it in *dst
|
||||
* @param src pointer to source AVDictionary struct
|
||||
* @param flags flags to use when setting entries in *dst
|
||||
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
|
||||
*/
|
||||
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
|
||||
|
||||
/**
|
||||
* Free all the memory allocated for an AVDictionary struct
|
||||
* and all keys and values.
|
||||
*/
|
||||
void av_dict_free(AVDictionary **m);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_DICT_H */
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* error code definitions
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ERROR_H
|
||||
#define AVUTIL_ERROR_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_error
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* error handling */
|
||||
#if EDOM > 0
|
||||
#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
|
||||
#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
|
||||
#else
|
||||
/* Some platforms have E* and errno already negated. */
|
||||
#define AVERROR(e) (e)
|
||||
#define AVUNERROR(e) (e)
|
||||
#endif
|
||||
|
||||
#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d))
|
||||
|
||||
#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
|
||||
#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
|
||||
#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
|
||||
#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
|
||||
#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
|
||||
#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
|
||||
#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
|
||||
#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
|
||||
#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
|
||||
#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
|
||||
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
|
||||
#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
|
||||
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
|
||||
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
|
||||
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
|
||||
|
||||
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
|
||||
/**
|
||||
* This is semantically identical to AVERROR_BUG
|
||||
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
|
||||
*/
|
||||
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
|
||||
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
|
||||
#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
|
||||
|
||||
#define AV_ERROR_MAX_STRING_SIZE 64
|
||||
|
||||
/**
|
||||
* Put a description of the AVERROR code errnum in errbuf.
|
||||
* In case of failure the global variable errno is set to indicate the
|
||||
* error. Even in case of failure av_strerror() will print a generic
|
||||
* error message indicating the errnum provided to errbuf.
|
||||
*
|
||||
* @param errnum error code to describe
|
||||
* @param errbuf buffer to which description is written
|
||||
* @param errbuf_size the size in bytes of errbuf
|
||||
* @return 0 on success, a negative value if a description for errnum
|
||||
* cannot be found
|
||||
*/
|
||||
int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
|
||||
|
||||
/**
|
||||
* Fill the provided buffer with a string containing an error string
|
||||
* corresponding to the AVERROR code errnum.
|
||||
*
|
||||
* @param errbuf a buffer
|
||||
* @param errbuf_size size in bytes of errbuf
|
||||
* @param errnum error code to describe
|
||||
* @return the buffer in input, filled with the error description
|
||||
* @see av_strerror()
|
||||
*/
|
||||
static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
|
||||
{
|
||||
av_strerror(errnum, errbuf, errbuf_size);
|
||||
return errbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience macro, the return value should be used only directly in
|
||||
* function arguments but never stand-alone.
|
||||
*/
|
||||
#define av_err2str(errnum) \
|
||||
av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_ERROR_H */
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* simple arithmetic expression evaluator
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_EVAL_H
|
||||
#define AVUTIL_EVAL_H
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
typedef struct AVExpr AVExpr;
|
||||
|
||||
/**
|
||||
* Parse and evaluate an expression.
|
||||
* Note, this is significantly slower than av_expr_eval().
|
||||
*
|
||||
* @param res a pointer to a double where is put the result value of
|
||||
* the expression, or NAN in case of error
|
||||
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
||||
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
||||
* @param const_values a zero terminated array of values for the identifiers from const_names
|
||||
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
|
||||
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
||||
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
||||
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @param log_ctx parent logging context
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_expr_parse_and_eval(double *res, const char *s,
|
||||
const char * const *const_names, const double *const_values,
|
||||
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
||||
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
||||
void *opaque, int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Parse an expression.
|
||||
*
|
||||
* @param expr a pointer where is put an AVExpr containing the parsed
|
||||
* value in case of successful parsing, or NULL otherwise.
|
||||
* The pointed to AVExpr must be freed with av_expr_free() by the user
|
||||
* when it is not needed anymore.
|
||||
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
||||
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
||||
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
|
||||
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
||||
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
||||
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
||||
* @param log_ctx parent logging context
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_expr_parse(AVExpr **expr, const char *s,
|
||||
const char * const *const_names,
|
||||
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
||||
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Evaluate a previously parsed expression.
|
||||
*
|
||||
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @return the value of the expression
|
||||
*/
|
||||
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
|
||||
|
||||
/**
|
||||
* Free a parsed expression previously created with av_expr_parse().
|
||||
*/
|
||||
void av_expr_free(AVExpr *e);
|
||||
|
||||
/**
|
||||
* Parse the string in numstr and return its value as a double. If
|
||||
* the string is empty, contains only whitespaces, or does not contain
|
||||
* an initial substring that has the expected syntax for a
|
||||
* floating-point number, no conversion is performed. In this case,
|
||||
* returns a value of zero and the value returned in tail is the value
|
||||
* of numstr.
|
||||
*
|
||||
* @param numstr a string representing a number, may contain one of
|
||||
* the International System number postfixes, for example 'K', 'M',
|
||||
* 'G'. If 'i' is appended after the postfix, powers of 2 are used
|
||||
* instead of powers of 10. The 'B' postfix multiplies the value for
|
||||
* 8, and can be appended after another postfix or used alone. This
|
||||
* allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
|
||||
* @param tail if non-NULL puts here the pointer to the char next
|
||||
* after the last parsed character
|
||||
*/
|
||||
double av_strtod(const char *numstr, char **tail);
|
||||
|
||||
#endif /* AVUTIL_EVAL_H */
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* a very simple circular buffer FIFO implementation
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FIFO_H
|
||||
#define AVUTIL_FIFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
|
||||
typedef struct AVFifoBuffer {
|
||||
uint8_t *buffer;
|
||||
uint8_t *rptr, *wptr, *end;
|
||||
uint32_t rndx, wndx;
|
||||
} AVFifoBuffer;
|
||||
|
||||
/**
|
||||
* Initialize an AVFifoBuffer.
|
||||
* @param size of FIFO
|
||||
* @return AVFifoBuffer or NULL in case of memory allocation failure
|
||||
*/
|
||||
AVFifoBuffer *av_fifo_alloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* Free an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to free
|
||||
*/
|
||||
void av_fifo_free(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
|
||||
* @param f AVFifoBuffer to reset
|
||||
*/
|
||||
void av_fifo_reset(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of data in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can read from it.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @return size
|
||||
*/
|
||||
int av_fifo_size(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of space in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can write into it.
|
||||
* @param f AVFifoBuffer to write into
|
||||
* @return size
|
||||
*/
|
||||
int av_fifo_space(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Feed data from an AVFifoBuffer to a user-supplied callback.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param buf_size number of bytes to read
|
||||
* @param func generic read function
|
||||
* @param dest data destination
|
||||
*/
|
||||
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Feed data from a user-supplied callback to an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to write to
|
||||
* @param src data source; non-const since it may be used as a
|
||||
* modifiable context by the function defined in func
|
||||
* @param size number of bytes to write
|
||||
* @param func generic write function; the first parameter is src,
|
||||
* the second is dest_buf, the third is dest_buf_size.
|
||||
* func must return the number of bytes written to dest_buf, or <= 0 to
|
||||
* indicate no more data available to write.
|
||||
* If func is NULL, src is interpreted as a simple byte array for source data.
|
||||
* @return the number of bytes written to the FIFO
|
||||
*/
|
||||
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Resize an AVFifoBuffer.
|
||||
* In case of reallocation failure, the old FIFO is kept unchanged.
|
||||
*
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param size new AVFifoBuffer size in bytes
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*/
|
||||
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
|
||||
|
||||
/**
|
||||
* Enlarge an AVFifoBuffer.
|
||||
* In case of reallocation failure, the old FIFO is kept unchanged.
|
||||
* The new fifo size may be larger than the requested size.
|
||||
*
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*/
|
||||
int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
|
||||
|
||||
/**
|
||||
* Read and discard the specified amount of data from an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param size amount of data to read in bytes
|
||||
*/
|
||||
void av_fifo_drain(AVFifoBuffer *f, int size);
|
||||
|
||||
/**
|
||||
* Return a pointer to the data stored in a FIFO buffer at a certain offset.
|
||||
* The FIFO buffer is not modified.
|
||||
*
|
||||
* @param f AVFifoBuffer to peek at, f must be non-NULL
|
||||
* @param offs an offset in bytes, its absolute value must be less
|
||||
* than the used buffer size or the returned pointer will
|
||||
* point outside to the buffer data.
|
||||
* The used buffer size can be checked with av_fifo_size().
|
||||
*/
|
||||
static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
|
||||
{
|
||||
uint8_t *ptr = f->rptr + offs;
|
||||
if (ptr >= f->end)
|
||||
ptr = f->buffer + (ptr - f->end);
|
||||
else if (ptr < f->buffer)
|
||||
ptr = f->end - (f->buffer - ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_FIFO_H */
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FILE_H
|
||||
#define AVUTIL_FILE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Misc file utilities.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read the file with name filename, and put its content in a newly
|
||||
* allocated buffer or map it with mmap() when available.
|
||||
* In case of success set *bufptr to the read or mmapped buffer, and
|
||||
* *size to the size in bytes of the buffer in *bufptr.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param log_offset loglevel offset used for logging
|
||||
* @param log_ctx context used for logging
|
||||
* @return a non negative number in case of success, a negative value
|
||||
* corresponding to an AVERROR error code in case of failure
|
||||
*/
|
||||
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Unmap or free the buffer bufptr created by av_file_map().
|
||||
*
|
||||
* @param size size in bytes of bufptr, must be the same as returned
|
||||
* by av_file_map()
|
||||
*/
|
||||
void av_file_unmap(uint8_t *bufptr, size_t size);
|
||||
|
||||
/**
|
||||
* Wrapper to work around the lack of mkstemp() on mingw.
|
||||
* Also, tries to create file in /tmp first, if possible.
|
||||
* *prefix can be a character constant; *filename will be allocated internally.
|
||||
* @return file descriptor of opened file (or -1 on error)
|
||||
* and opened file name in **filename.
|
||||
* @note On very old libcs it is necessary to set a secure umask before
|
||||
* calling this, av_tempfile() cant call umask itself as it is used in
|
||||
* libraries and could interfere with the calling application.
|
||||
*/
|
||||
int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
|
||||
|
||||
#endif /* AVUTIL_FILE_H */
|
||||
@@ -1,200 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_IMGUTILS_H
|
||||
#define AVUTIL_IMGUTILS_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* misc image utilities
|
||||
*
|
||||
* @addtogroup lavu_picture
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "pixdesc.h"
|
||||
|
||||
/**
|
||||
* Compute the max pixel step for each plane of an image with a
|
||||
* format described by pixdesc.
|
||||
*
|
||||
* The pixel step is the distance in bytes between the first byte of
|
||||
* the group of bytes which describe a pixel component and the first
|
||||
* byte of the successive group in the same plane for the same
|
||||
* component.
|
||||
*
|
||||
* @param max_pixsteps an array which is filled with the max pixel step
|
||||
* for each plane. Since a plane may contain different pixel
|
||||
* components, the computed max_pixsteps[plane] is relative to the
|
||||
* component in the plane with the max pixel step.
|
||||
* @param max_pixstep_comps an array which is filled with the component
|
||||
* for each plane which has the max pixel step. May be NULL.
|
||||
*/
|
||||
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
|
||||
const AVPixFmtDescriptor *pixdesc);
|
||||
|
||||
/**
|
||||
* Compute the size of an image line with format pix_fmt and width
|
||||
* width for the plane plane.
|
||||
*
|
||||
* @return the computed size in bytes
|
||||
*/
|
||||
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
|
||||
|
||||
/**
|
||||
* Fill plane linesizes for an image with pixel format pix_fmt and
|
||||
* width width.
|
||||
*
|
||||
* @param linesizes array to be filled with the linesize for each plane
|
||||
* @return >= 0 in case of success, a negative error code otherwise
|
||||
*/
|
||||
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
|
||||
|
||||
/**
|
||||
* Fill plane data pointers for an image with pixel format pix_fmt and
|
||||
* height height.
|
||||
*
|
||||
* @param data pointers array to be filled with the pointer for each image plane
|
||||
* @param ptr the pointer to a buffer which will contain the image
|
||||
* @param linesizes the array containing the linesize for each
|
||||
* plane, should be filled by av_image_fill_linesizes()
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
*/
|
||||
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
|
||||
uint8_t *ptr, const int linesizes[4]);
|
||||
|
||||
/**
|
||||
* Allocate an image with size w and h and pixel format pix_fmt, and
|
||||
* fill pointers and linesizes accordingly.
|
||||
* The allocated image buffer has to be freed by using
|
||||
* av_freep(&pointers[0]).
|
||||
*
|
||||
* @param align the value to use for buffer size alignment
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
*/
|
||||
int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
|
||||
int w, int h, enum AVPixelFormat pix_fmt, int align);
|
||||
|
||||
/**
|
||||
* Copy image plane from src to dst.
|
||||
* That is, copy "height" number of lines of "bytewidth" bytes each.
|
||||
* The first byte of each successive line is separated by *_linesize
|
||||
* bytes.
|
||||
*
|
||||
* bytewidth must be contained by both absolute values of dst_linesize
|
||||
* and src_linesize, otherwise the function behavior is undefined.
|
||||
*
|
||||
* @param dst_linesize linesize for the image plane in dst
|
||||
* @param src_linesize linesize for the image plane in src
|
||||
*/
|
||||
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
|
||||
const uint8_t *src, int src_linesize,
|
||||
int bytewidth, int height);
|
||||
|
||||
/**
|
||||
* Copy image in src_data to dst_data.
|
||||
*
|
||||
* @param dst_linesizes linesizes for the image in dst_data
|
||||
* @param src_linesizes linesizes for the image in src_data
|
||||
*/
|
||||
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
|
||||
const uint8_t *src_data[4], const int src_linesizes[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height);
|
||||
|
||||
/**
|
||||
* Setup the data pointers and linesizes based on the specified image
|
||||
* parameters and the provided array.
|
||||
*
|
||||
* The fields of the given image are filled in by using the src
|
||||
* address which points to the image data buffer. Depending on the
|
||||
* specified pixel format, one or multiple image data pointers and
|
||||
* line sizes will be set. If a planar format is specified, several
|
||||
* pointers will be set pointing to the different picture planes and
|
||||
* the line sizes of the different planes will be stored in the
|
||||
* lines_sizes array. Call with src == NULL to get the required
|
||||
* size for the src buffer.
|
||||
*
|
||||
* To allocate the buffer and fill in the dst_data and dst_linesize in
|
||||
* one call, use av_image_alloc().
|
||||
*
|
||||
* @param dst_data data pointers to be filled in
|
||||
* @param dst_linesizes linesizes for the image in dst_data to be filled in
|
||||
* @param src buffer which will contain or contains the actual image data, can be NULL
|
||||
* @param pix_fmt the pixel format of the image
|
||||
* @param width the width of the image in pixels
|
||||
* @param height the height of the image in pixels
|
||||
* @param align the value used in src for linesize alignment
|
||||
* @return the size in bytes required for src, a negative error code
|
||||
* in case of failure
|
||||
*/
|
||||
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
|
||||
const uint8_t *src,
|
||||
enum AVPixelFormat pix_fmt, int width, int height, int align);
|
||||
|
||||
/**
|
||||
* Return the size in bytes of the amount of data required to store an
|
||||
* image with the given parameters.
|
||||
*
|
||||
* @param[in] align the assumed linesize alignment
|
||||
*/
|
||||
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
|
||||
|
||||
/**
|
||||
* Copy image data from an image into a buffer.
|
||||
*
|
||||
* av_image_get_buffer_size() can be used to compute the required size
|
||||
* for the buffer to fill.
|
||||
*
|
||||
* @param dst a buffer into which picture data will be copied
|
||||
* @param dst_size the size in bytes of dst
|
||||
* @param src_data pointers containing the source image data
|
||||
* @param src_linesizes linesizes for the image in src_data
|
||||
* @param pix_fmt the pixel format of the source image
|
||||
* @param width the width of the source image in pixels
|
||||
* @param height the height of the source image in pixels
|
||||
* @param align the assumed linesize alignment for dst
|
||||
* @return the number of bytes written to dst, or a negative value
|
||||
* (error code) on error
|
||||
*/
|
||||
int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
|
||||
const uint8_t * const src_data[4], const int src_linesize[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height, int align);
|
||||
|
||||
/**
|
||||
* Check if the given dimension of an image is valid, meaning that all
|
||||
* bytes of the image can be addressed with a signed int.
|
||||
*
|
||||
* @param w the width of the picture
|
||||
* @param h the height of the picture
|
||||
* @param log_offset the offset to sum to the log level for logging with log_ctx
|
||||
* @param log_ctx the parent logging context, it may be NULL
|
||||
* @return >= 0 if valid, a negative error code otherwise
|
||||
*/
|
||||
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
|
||||
|
||||
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif /* AVUTIL_IMGUTILS_H */
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Mans Rullgard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav 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.
|
||||
*
|
||||
* Libav 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 Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTFLOAT_H
|
||||
#define AVUTIL_INTFLOAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
union av_intfloat32 {
|
||||
uint32_t i;
|
||||
float f;
|
||||
};
|
||||
|
||||
union av_intfloat64 {
|
||||
uint64_t i;
|
||||
double f;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reinterpret a 32-bit integer as a float.
|
||||
*/
|
||||
static av_always_inline float av_int2float(uint32_t i)
|
||||
{
|
||||
union av_intfloat32 v;
|
||||
v.i = i;
|
||||
return v.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a float as a 32-bit integer.
|
||||
*/
|
||||
static av_always_inline uint32_t av_float2int(float f)
|
||||
{
|
||||
union av_intfloat32 v;
|
||||
v.f = f;
|
||||
return v.i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a 64-bit integer as a double.
|
||||
*/
|
||||
static av_always_inline double av_int2double(uint64_t i)
|
||||
{
|
||||
union av_intfloat64 v;
|
||||
v.i = i;
|
||||
return v.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a double as a 64-bit integer.
|
||||
*/
|
||||
static av_always_inline uint64_t av_double2int(double f)
|
||||
{
|
||||
union av_intfloat64 v;
|
||||
v.f = f;
|
||||
return v.i;
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_INTFLOAT_H */
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTFLOAT_READWRITE_H
|
||||
#define AVUTIL_INTFLOAT_READWRITE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/* IEEE 80 bits extended float */
|
||||
typedef struct AVExtFloat {
|
||||
uint8_t exponent[2];
|
||||
uint8_t mantissa[8];
|
||||
} AVExtFloat;
|
||||
|
||||
attribute_deprecated double av_int2dbl(int64_t v) av_const;
|
||||
attribute_deprecated float av_int2flt(int32_t v) av_const;
|
||||
attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const;
|
||||
attribute_deprecated int64_t av_dbl2int(double d) av_const;
|
||||
attribute_deprecated int32_t av_flt2int(float d) av_const;
|
||||
attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const;
|
||||
|
||||
#endif /* AVUTIL_INTFLOAT_READWRITE_H */
|
||||
@@ -1,555 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTREADWRITE_H
|
||||
#define AVUTIL_INTREADWRITE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/avconfig.h"
|
||||
#include "attributes.h"
|
||||
#include "bswap.h"
|
||||
|
||||
typedef union {
|
||||
uint64_t u64;
|
||||
uint32_t u32[2];
|
||||
uint16_t u16[4];
|
||||
uint8_t u8 [8];
|
||||
double f64;
|
||||
float f32[2];
|
||||
} av_alias av_alias64;
|
||||
|
||||
typedef union {
|
||||
uint32_t u32;
|
||||
uint16_t u16[2];
|
||||
uint8_t u8 [4];
|
||||
float f32;
|
||||
} av_alias av_alias32;
|
||||
|
||||
typedef union {
|
||||
uint16_t u16;
|
||||
uint8_t u8 [2];
|
||||
} av_alias av_alias16;
|
||||
|
||||
/*
|
||||
* Arch-specific headers can provide any combination of
|
||||
* AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
|
||||
* Preprocessor symbols must be defined, even if these are implemented
|
||||
* as inline functions.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/intreadwrite.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/intreadwrite.h"
|
||||
#elif ARCH_MIPS
|
||||
# include "mips/intreadwrite.h"
|
||||
#elif ARCH_PPC
|
||||
# include "ppc/intreadwrite.h"
|
||||
#elif ARCH_TOMI
|
||||
# include "tomi/intreadwrite.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/intreadwrite.h"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
/*
|
||||
* Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
|
||||
*/
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
|
||||
# if defined(AV_RN16) && !defined(AV_RB16)
|
||||
# define AV_RB16(p) AV_RN16(p)
|
||||
# elif !defined(AV_RN16) && defined(AV_RB16)
|
||||
# define AV_RN16(p) AV_RB16(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN16) && !defined(AV_WB16)
|
||||
# define AV_WB16(p, v) AV_WN16(p, v)
|
||||
# elif !defined(AV_WN16) && defined(AV_WB16)
|
||||
# define AV_WN16(p, v) AV_WB16(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN24) && !defined(AV_RB24)
|
||||
# define AV_RB24(p) AV_RN24(p)
|
||||
# elif !defined(AV_RN24) && defined(AV_RB24)
|
||||
# define AV_RN24(p) AV_RB24(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN24) && !defined(AV_WB24)
|
||||
# define AV_WB24(p, v) AV_WN24(p, v)
|
||||
# elif !defined(AV_WN24) && defined(AV_WB24)
|
||||
# define AV_WN24(p, v) AV_WB24(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN32) && !defined(AV_RB32)
|
||||
# define AV_RB32(p) AV_RN32(p)
|
||||
# elif !defined(AV_RN32) && defined(AV_RB32)
|
||||
# define AV_RN32(p) AV_RB32(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN32) && !defined(AV_WB32)
|
||||
# define AV_WB32(p, v) AV_WN32(p, v)
|
||||
# elif !defined(AV_WN32) && defined(AV_WB32)
|
||||
# define AV_WN32(p, v) AV_WB32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN64) && !defined(AV_RB64)
|
||||
# define AV_RB64(p) AV_RN64(p)
|
||||
# elif !defined(AV_RN64) && defined(AV_RB64)
|
||||
# define AV_RN64(p) AV_RB64(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN64) && !defined(AV_WB64)
|
||||
# define AV_WB64(p, v) AV_WN64(p, v)
|
||||
# elif !defined(AV_WN64) && defined(AV_WB64)
|
||||
# define AV_WN64(p, v) AV_WB64(p, v)
|
||||
# endif
|
||||
|
||||
#else /* AV_HAVE_BIGENDIAN */
|
||||
|
||||
# if defined(AV_RN16) && !defined(AV_RL16)
|
||||
# define AV_RL16(p) AV_RN16(p)
|
||||
# elif !defined(AV_RN16) && defined(AV_RL16)
|
||||
# define AV_RN16(p) AV_RL16(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN16) && !defined(AV_WL16)
|
||||
# define AV_WL16(p, v) AV_WN16(p, v)
|
||||
# elif !defined(AV_WN16) && defined(AV_WL16)
|
||||
# define AV_WN16(p, v) AV_WL16(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN24) && !defined(AV_RL24)
|
||||
# define AV_RL24(p) AV_RN24(p)
|
||||
# elif !defined(AV_RN24) && defined(AV_RL24)
|
||||
# define AV_RN24(p) AV_RL24(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN24) && !defined(AV_WL24)
|
||||
# define AV_WL24(p, v) AV_WN24(p, v)
|
||||
# elif !defined(AV_WN24) && defined(AV_WL24)
|
||||
# define AV_WN24(p, v) AV_WL24(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN32) && !defined(AV_RL32)
|
||||
# define AV_RL32(p) AV_RN32(p)
|
||||
# elif !defined(AV_RN32) && defined(AV_RL32)
|
||||
# define AV_RN32(p) AV_RL32(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN32) && !defined(AV_WL32)
|
||||
# define AV_WL32(p, v) AV_WN32(p, v)
|
||||
# elif !defined(AV_WN32) && defined(AV_WL32)
|
||||
# define AV_WN32(p, v) AV_WL32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN64) && !defined(AV_RL64)
|
||||
# define AV_RL64(p) AV_RN64(p)
|
||||
# elif !defined(AV_RN64) && defined(AV_RL64)
|
||||
# define AV_RN64(p) AV_RL64(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN64) && !defined(AV_WL64)
|
||||
# define AV_WL64(p, v) AV_WN64(p, v)
|
||||
# elif !defined(AV_WN64) && defined(AV_WL64)
|
||||
# define AV_WN64(p, v) AV_WL64(p, v)
|
||||
# endif
|
||||
|
||||
#endif /* !AV_HAVE_BIGENDIAN */
|
||||
|
||||
/*
|
||||
* Define AV_[RW]N helper macros to simplify definitions not provided
|
||||
* by per-arch headers.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__)
|
||||
|
||||
union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
|
||||
union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
|
||||
union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
||||
|
||||
# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
|
||||
# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
|
||||
|
||||
#elif defined(__DECC)
|
||||
|
||||
# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
|
||||
# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
|
||||
|
||||
#elif AV_HAVE_FAST_UNALIGNED
|
||||
|
||||
# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
|
||||
# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
|
||||
|
||||
#else
|
||||
|
||||
#ifndef AV_RB16
|
||||
# define AV_RB16(x) \
|
||||
((((const uint8_t*)(x))[0] << 8) | \
|
||||
((const uint8_t*)(x))[1])
|
||||
#endif
|
||||
#ifndef AV_WB16
|
||||
# define AV_WB16(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[1] = (d); \
|
||||
((uint8_t*)(p))[0] = (d)>>8; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL16
|
||||
# define AV_RL16(x) \
|
||||
((((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL16
|
||||
# define AV_WL16(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB32
|
||||
# define AV_RB32(x) \
|
||||
(((uint32_t)((const uint8_t*)(x))[0] << 24) | \
|
||||
(((const uint8_t*)(x))[1] << 16) | \
|
||||
(((const uint8_t*)(x))[2] << 8) | \
|
||||
((const uint8_t*)(x))[3])
|
||||
#endif
|
||||
#ifndef AV_WB32
|
||||
# define AV_WB32(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[3] = (d); \
|
||||
((uint8_t*)(p))[2] = (d)>>8; \
|
||||
((uint8_t*)(p))[1] = (d)>>16; \
|
||||
((uint8_t*)(p))[0] = (d)>>24; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL32
|
||||
# define AV_RL32(x) \
|
||||
(((uint32_t)((const uint8_t*)(x))[3] << 24) | \
|
||||
(((const uint8_t*)(x))[2] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL32
|
||||
# define AV_WL32(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
((uint8_t*)(p))[3] = (d)>>24; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB64
|
||||
# define AV_RB64(x) \
|
||||
(((uint64_t)((const uint8_t*)(x))[0] << 56) | \
|
||||
((uint64_t)((const uint8_t*)(x))[1] << 48) | \
|
||||
((uint64_t)((const uint8_t*)(x))[2] << 40) | \
|
||||
((uint64_t)((const uint8_t*)(x))[3] << 32) | \
|
||||
((uint64_t)((const uint8_t*)(x))[4] << 24) | \
|
||||
((uint64_t)((const uint8_t*)(x))[5] << 16) | \
|
||||
((uint64_t)((const uint8_t*)(x))[6] << 8) | \
|
||||
(uint64_t)((const uint8_t*)(x))[7])
|
||||
#endif
|
||||
#ifndef AV_WB64
|
||||
# define AV_WB64(p, darg) do { \
|
||||
uint64_t d = (darg); \
|
||||
((uint8_t*)(p))[7] = (d); \
|
||||
((uint8_t*)(p))[6] = (d)>>8; \
|
||||
((uint8_t*)(p))[5] = (d)>>16; \
|
||||
((uint8_t*)(p))[4] = (d)>>24; \
|
||||
((uint8_t*)(p))[3] = (d)>>32; \
|
||||
((uint8_t*)(p))[2] = (d)>>40; \
|
||||
((uint8_t*)(p))[1] = (d)>>48; \
|
||||
((uint8_t*)(p))[0] = (d)>>56; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL64
|
||||
# define AV_RL64(x) \
|
||||
(((uint64_t)((const uint8_t*)(x))[7] << 56) | \
|
||||
((uint64_t)((const uint8_t*)(x))[6] << 48) | \
|
||||
((uint64_t)((const uint8_t*)(x))[5] << 40) | \
|
||||
((uint64_t)((const uint8_t*)(x))[4] << 32) | \
|
||||
((uint64_t)((const uint8_t*)(x))[3] << 24) | \
|
||||
((uint64_t)((const uint8_t*)(x))[2] << 16) | \
|
||||
((uint64_t)((const uint8_t*)(x))[1] << 8) | \
|
||||
(uint64_t)((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL64
|
||||
# define AV_WL64(p, darg) do { \
|
||||
uint64_t d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
((uint8_t*)(p))[3] = (d)>>24; \
|
||||
((uint8_t*)(p))[4] = (d)>>32; \
|
||||
((uint8_t*)(p))[5] = (d)>>40; \
|
||||
((uint8_t*)(p))[6] = (d)>>48; \
|
||||
((uint8_t*)(p))[7] = (d)>>56; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_RN(s, p) AV_RB##s(p)
|
||||
# define AV_WN(s, p, v) AV_WB##s(p, v)
|
||||
#else
|
||||
# define AV_RN(s, p) AV_RL##s(p)
|
||||
# define AV_WN(s, p, v) AV_WL##s(p, v)
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_FAST_UNALIGNED */
|
||||
|
||||
#ifndef AV_RN16
|
||||
# define AV_RN16(p) AV_RN(16, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN32
|
||||
# define AV_RN32(p) AV_RN(32, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN64
|
||||
# define AV_RN64(p) AV_RN(64, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN16
|
||||
# define AV_WN16(p, v) AV_WN(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN32
|
||||
# define AV_WN32(p, v) AV_WN(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN64
|
||||
# define AV_WN64(p, v) AV_WN(64, p, v)
|
||||
#endif
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_RB(s, p) AV_RN##s(p)
|
||||
# define AV_WB(s, p, v) AV_WN##s(p, v)
|
||||
# define AV_RL(s, p) av_bswap##s(AV_RN##s(p))
|
||||
# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v))
|
||||
#else
|
||||
# define AV_RB(s, p) av_bswap##s(AV_RN##s(p))
|
||||
# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))
|
||||
# define AV_RL(s, p) AV_RN##s(p)
|
||||
# define AV_WL(s, p, v) AV_WN##s(p, v)
|
||||
#endif
|
||||
|
||||
#define AV_RB8(x) (((const uint8_t*)(x))[0])
|
||||
#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
|
||||
|
||||
#define AV_RL8(x) AV_RB8(x)
|
||||
#define AV_WL8(p, d) AV_WB8(p, d)
|
||||
|
||||
#ifndef AV_RB16
|
||||
# define AV_RB16(p) AV_RB(16, p)
|
||||
#endif
|
||||
#ifndef AV_WB16
|
||||
# define AV_WB16(p, v) AV_WB(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL16
|
||||
# define AV_RL16(p) AV_RL(16, p)
|
||||
#endif
|
||||
#ifndef AV_WL16
|
||||
# define AV_WL16(p, v) AV_WL(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB32
|
||||
# define AV_RB32(p) AV_RB(32, p)
|
||||
#endif
|
||||
#ifndef AV_WB32
|
||||
# define AV_WB32(p, v) AV_WB(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL32
|
||||
# define AV_RL32(p) AV_RL(32, p)
|
||||
#endif
|
||||
#ifndef AV_WL32
|
||||
# define AV_WL32(p, v) AV_WL(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB64
|
||||
# define AV_RB64(p) AV_RB(64, p)
|
||||
#endif
|
||||
#ifndef AV_WB64
|
||||
# define AV_WB64(p, v) AV_WB(64, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL64
|
||||
# define AV_RL64(p) AV_RL(64, p)
|
||||
#endif
|
||||
#ifndef AV_WL64
|
||||
# define AV_WL64(p, v) AV_WL(64, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB24
|
||||
# define AV_RB24(x) \
|
||||
((((const uint8_t*)(x))[0] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[2])
|
||||
#endif
|
||||
#ifndef AV_WB24
|
||||
# define AV_WB24(p, d) do { \
|
||||
((uint8_t*)(p))[2] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[0] = (d)>>16; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL24
|
||||
# define AV_RL24(x) \
|
||||
((((const uint8_t*)(x))[2] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL24
|
||||
# define AV_WL24(p, d) do { \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The AV_[RW]NA macros access naturally aligned data
|
||||
* in a type-safe way.
|
||||
*/
|
||||
|
||||
#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
|
||||
#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
|
||||
|
||||
#ifndef AV_RN16A
|
||||
# define AV_RN16A(p) AV_RNA(16, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN32A
|
||||
# define AV_RN32A(p) AV_RNA(32, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN64A
|
||||
# define AV_RN64A(p) AV_RNA(64, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN16A
|
||||
# define AV_WN16A(p, v) AV_WNA(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN32A
|
||||
# define AV_WN32A(p, v) AV_WNA(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN64A
|
||||
# define AV_WN64A(p, v) AV_WNA(64, p, v)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The AV_COPYxxU macros are suitable for copying data to/from unaligned
|
||||
* memory locations.
|
||||
*/
|
||||
|
||||
#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
|
||||
|
||||
#ifndef AV_COPY16U
|
||||
# define AV_COPY16U(d, s) AV_COPYU(16, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY32U
|
||||
# define AV_COPY32U(d, s) AV_COPYU(32, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY64U
|
||||
# define AV_COPY64U(d, s) AV_COPYU(64, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY128U
|
||||
# define AV_COPY128U(d, s) \
|
||||
do { \
|
||||
AV_COPY64U(d, s); \
|
||||
AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
||||
* naturally aligned. They may be implemented using MMX,
|
||||
* so emms_c() must be called before using any float code
|
||||
* afterwards.
|
||||
*/
|
||||
|
||||
#define AV_COPY(n, d, s) \
|
||||
(((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
|
||||
|
||||
#ifndef AV_COPY16
|
||||
# define AV_COPY16(d, s) AV_COPY(16, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY32
|
||||
# define AV_COPY32(d, s) AV_COPY(32, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY64
|
||||
# define AV_COPY64(d, s) AV_COPY(64, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY128
|
||||
# define AV_COPY128(d, s) \
|
||||
do { \
|
||||
AV_COPY64(d, s); \
|
||||
AV_COPY64((char*)(d)+8, (char*)(s)+8); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
|
||||
|
||||
#ifndef AV_SWAP64
|
||||
# define AV_SWAP64(a, b) AV_SWAP(64, a, b)
|
||||
#endif
|
||||
|
||||
#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
|
||||
|
||||
#ifndef AV_ZERO16
|
||||
# define AV_ZERO16(d) AV_ZERO(16, d)
|
||||
#endif
|
||||
|
||||
#ifndef AV_ZERO32
|
||||
# define AV_ZERO32(d) AV_ZERO(32, d)
|
||||
#endif
|
||||
|
||||
#ifndef AV_ZERO64
|
||||
# define AV_ZERO64(d) AV_ZERO(64, d)
|
||||
#endif
|
||||
|
||||
#ifndef AV_ZERO128
|
||||
# define AV_ZERO128(d) \
|
||||
do { \
|
||||
AV_ZERO64(d); \
|
||||
AV_ZERO64((char*)(d)+8); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_INTREADWRITE_H */
|
||||
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user