mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
MSET用のImageDBを追加
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@690 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
0d14ccf41e
commit
e4fddb3dda
496
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDatabase.h
Normal file
496
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDatabase.h
Normal file
@ -0,0 +1,496 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDatabase.h
|
||||
|
||||
映像データベース
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DATABASE_H_
|
||||
#define IMAGE_DATABASE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbSingleton.h"
|
||||
#include "ImageDbResult.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbSearchObject.h"
|
||||
#include "ImageDbRecord.h"
|
||||
#include "ImageDbRecordParam.h"
|
||||
#include "ImageDbPictureDatabase.h"
|
||||
#include "ImageDbImageCollector.h"
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースクラス
|
||||
@details
|
||||
NANDやSDカードに保存されている写真(動画)を管理するための機能を提供します。
|
||||
TWLのTCLライブラリの管理ファイル操作関連に似せています。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageDatabase : public Singleton<ImageDatabase>
|
||||
{
|
||||
friend class ImageDbSearchObject;
|
||||
friend class Allocator;
|
||||
|
||||
public:
|
||||
//------------------------------------------------------------------------
|
||||
// 初期化関連
|
||||
//------------------------------------------------------------------------
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像データベースを初期化する
|
||||
@param[in] bInitDbNand NAND側データベースを使用するフラグ
|
||||
@param[in] bInitDbSd SD側データベースを使用するフラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(bool bInitDbNand, bool bInitDbSd);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像データベースを終了する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Finalize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像データベースが初期化済みかチェックする
|
||||
@return 初期化済みならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種処理の中止要求を行う
|
||||
@details
|
||||
別スレッドから処理中止を要求します。
|
||||
ImageDbはスレッドセーフではありませんが、本関数は別スレッドから呼び出す
|
||||
ことができます。
|
||||
中止要求は各種処理関数が内部処理の直前でクリアします。そのため確実に中止
|
||||
するには本関数を呼び出し続ける必要があります。
|
||||
本関数で中止が行われるのは以下の関数となります。
|
||||
LoadDatabase()
|
||||
RestoreDatabase()
|
||||
ReflectImageCollector()
|
||||
-----------------------------------------------------------------------*/
|
||||
void StopProcess();
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// データベース関連
|
||||
//-----------------------------------------------------------------------
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 復元処理が必要か調べる
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@return 復元処理が必要な場合はtrue
|
||||
@details
|
||||
復元処理が必要な状態になると、データベースを変更する処理は失敗し、
|
||||
ResultErrorNeedRestoreを返すようになります。その場合はRestoreDatabase()
|
||||
を呼び出して復元処理を行う必要があります。
|
||||
指定のデータベースを利用していなければfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsNeedRestore(StorageType eStoType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理ファイルを読み込む
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@details
|
||||
既存の管理ファイルは破棄されてから読み込まれます。
|
||||
ロードする管理ファイルが見つからなかった場合はロード失敗となります。
|
||||
管理ファイルの痕跡が見つかり、復元の処理が必要になった場合は
|
||||
ResultErrorNeedRestoreを返します。その状態になるとデータベースを変更す
|
||||
る処理は失敗し、ResultErrorNeedRestoreを返すようになります。その場合は
|
||||
RestoreDatabase()を呼び出して復元処理を行う必要があります。
|
||||
指定のデータベースを利用していなければ何もせずにResultSuccessを返します。
|
||||
本関数はStopProcess()で処理を中止することができます。
|
||||
中止した場合はResultErrorStoppedを返し、対象データベースは修復処理が必要
|
||||
な状態となります(IsNeedRestore()がtrue)。そのため中止後に続けてデータ
|
||||
ベースを利用したい場合は、修復や再読み込み等を行い復元する必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result LoadDatabase(StorageType eStoType);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief より新しい管理ファイルが存在するか調べる
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@return 存在する場合はtrue
|
||||
@details
|
||||
現在メモリに保持しているデータベースより、新しいデータベースがファイルに
|
||||
存在するかチェックします。
|
||||
存在していた場合は、データベースに変更を加える操作が行われる処理内で、自
|
||||
動で新しいデーベースに更新されます。
|
||||
すぐに更新したい場合はLoadDatabase()で手動で更新してください。
|
||||
指定のデータベースを利用していなければfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsExistNewerDatabase(StorageType eStoType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理ファイルを復元する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@details
|
||||
存在する映像ファイルを調べて管理ファイルを復元します。
|
||||
復元処理は非常に時間がかかります。
|
||||
指定のデータベースを利用していなければ何もせずにResultSuccessを返します。
|
||||
本関数はStopProcess()で処理を中止することができます。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result RestoreDatabase(StorageType eStoType);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理ファイルを新しく生成する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@details
|
||||
既存の管理ファイルは破棄されてから生成されます。
|
||||
指定のデータベースを利用していなければ何もせずにResultSuccessを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result CreateDatabase(StorageType eStoType);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// 画像登録関連
|
||||
//------------------------------------------------------------------------
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の空き管理数を取得する
|
||||
@param[in] eStoType 確認先のストレージ
|
||||
@return 空き管理数
|
||||
@details
|
||||
指定のデータベースを利用していなければゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetEmptyImageNum(StorageType eStoType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の使用済み管理数を取得する
|
||||
@param[in] eStoType 確認先のストレージ
|
||||
@return 使用済み管理数
|
||||
@details
|
||||
指定のデータベースを利用していなければゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRegisteredImageNum(StorageType eStoType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の最大管理数を取得する
|
||||
@param[in] eStoType 確認先のストレージ
|
||||
@return 最大管理数
|
||||
@details
|
||||
指定のデータベースを利用していなければゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetMaxImageNum(StorageType eStoType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像を管理ファイルに仮登録する
|
||||
@param[in] eStoType 登録先のストレージ
|
||||
@param[in] eImgKind 登録する映像の種類
|
||||
@param[in] rRecParam 登録する映像情報
|
||||
@param[in] bSave 仮登録後に管理ファイルを保存するフラグ
|
||||
@param[out] pLink 登録した映像情報のレコード ヌル不可
|
||||
@details
|
||||
独自で映像をストレージへ保存する場合は、この関数で管理ファイルに仮登録
|
||||
し、pLinkから求まるファイルパスへ保存してください。
|
||||
ファイルへの保存が終了したら、RegisterImagePost()で仮登録を正式登録に
|
||||
します。
|
||||
指定のデータベースを利用していなければ何もせずにResultErrorを返します。
|
||||
rRecParamはPost側でも指定できます。Pre側の段階で設定できる情報はできる
|
||||
だけPre側で設定してください。これは何かしらの理由でPostが行えなかったと
|
||||
きの保険となります。
|
||||
|
||||
bSaveにfalseを指定すると管理ファイルの保存は行われません。
|
||||
保存はされなくてもメモリ上には記録されており、RegisterImagePost()などの
|
||||
他の保存が関わる操作を行うと、その時一緒に管理ファイルへ保存はされます。
|
||||
特別な理由がない限りtrueを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result RegisterImagePre(
|
||||
StorageType eStoType, ImageKind eImgKind,
|
||||
const ImageDbRecordParam& rRecParam, bool bSave,
|
||||
ImageDbRecordLink* pLink);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 仮登録の映像を正式登録にする
|
||||
@param[in] rLink 対象の映像情報のレコード
|
||||
@param[in] rRecParam 登録する映像情報
|
||||
@param[in] nImageDataSize 対処の映像のデータサイズ
|
||||
@details
|
||||
独自で映像をストレージへ保存する場合は、この関数で管理ファイルに仮登録し、
|
||||
pLinkから求まるファイルパスへ保存してください。
|
||||
ファイルへの保存が終了したら、この関数で仮登録を正式登録にします。
|
||||
指定のデータベースを利用していなければ何もせずにResultErrorを返します。
|
||||
Pre側で設定した映像情報はPost側の設定ですべて上書きされます。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result RegisterImagePost(
|
||||
const ImageDbRecordLink& rLink,
|
||||
const ImageDbRecordParam& rRecParam, std::size_t nImageDataSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGを管理ファイルに登録する
|
||||
@param[in] eStoType 登録先のストレージ
|
||||
@param[in] pJpegData 登録するJPEGデータ
|
||||
@param[in] nJpegDataSize 登録するJPEGデータのサイズ
|
||||
@param[in] rRecParam 登録する映像情報
|
||||
@param[out] pLink 登録した映像情報のレコード ヌル可
|
||||
@details
|
||||
指定されたJPEGを管理ファイルに登録し、対象のストレージへ保存します。
|
||||
nSecondを省略した場合は現在の時間が設定されます。
|
||||
指定のデータベースを利用していなければ何もせずにResultErrorを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result RegisterJpeg(
|
||||
StorageType eStoType,
|
||||
const void* pJpegData, std::size_t nJpegDataSize,
|
||||
const ImageDbRecordParam& rRecParam,
|
||||
ImageDbRecordLink* pLink = 0);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPを管理ファイルに登録する
|
||||
@param[in] eStoType 登録先のストレージ
|
||||
@param[in] pMpData 登録するMPデータ
|
||||
@param[in] nMpDataSize 登録するMPデータのサイズ
|
||||
@param[in] pJpegData 登録するJPEGデータ
|
||||
@param[in] nJpegDataSize 登録するJPEGデータのサイズ
|
||||
@param[in] rRecParam 登録する映像情報
|
||||
@param[out] pLink 登録した映像情報のレコード ヌル可
|
||||
@details
|
||||
指定されたMPを管理ファイルに登録し、対象のストレージへ保存します。
|
||||
JPEGデータの指定がない場合は、MPデータの左画像が利用されます。
|
||||
(その際のJPEGのExifはMPデータのExifをもとに設定されます)
|
||||
nSecondを省略した場合は現在の時間が設定されます。
|
||||
指定のデータベースを利用していなければ何もせずにResultErrorを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
Result RegisterMp(
|
||||
StorageType eStoType,
|
||||
const void* pMpData, std::size_t nMpDataSize,
|
||||
const ImageDbRecordParam& rRecParam,
|
||||
ImageDbRecordLink* pLink = 0);
|
||||
#if 0
|
||||
Result RegisterMp(
|
||||
StorageType eStoType,
|
||||
const void* pMpData, std::size_t nMpDataSize,
|
||||
const void* pJpegData, std::size_t nJpegDataSize,
|
||||
const ImageDbRecordParam& rRecParam,
|
||||
ImageDbRecordLink* pLink = 0);
|
||||
#endif
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像を管理ファイルから削除する
|
||||
@param[in] rLink 削除する映像情報のレコード
|
||||
@param[in] eStoType 削除ストレージ
|
||||
@param[out] pUnregNum 削除に成功した映像数 ヌル可
|
||||
@param[out] pTotalNum 削除対象となった映像数 ヌル可
|
||||
@details
|
||||
映像ファイルも削除されます。
|
||||
ストレージを指定した場合は、その中のすべての映像が削除されます。
|
||||
指定のデータベースを利用していなければ何もせずにResultErrorを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
Result UnregisterImage(const ImageDbRecordLink& rLink);
|
||||
Result UnregisterImage(StorageType eStoType, int* pUnregNum = 0, int *pTotalNum = 0);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像を複製する
|
||||
@param[in] rLinkSrc 複製元の映像情報のレコード
|
||||
@param[in] eStoTypeSrc 複製元のストレージ
|
||||
@param[in] pSrcData 複製元のデータ
|
||||
@param[in] nSrcDataSize 複製元のデータサイズ
|
||||
@param[in] eStoTypeDst 複製先のストレージ
|
||||
@param[out] pLinkDst 複製後のレコードリンク ヌル可
|
||||
@param[out] rResultSrc 転送元の処理結果
|
||||
@param[out] rResultDst 転送先の処理結果
|
||||
@details
|
||||
複製元のデータが既にメモリ上に存在する場合は、pSrcDataとnSrcDataSizeで
|
||||
そのデータを指定するとファイルから読み込むことなく複製できます。
|
||||
その際JPEGやMPなど適切なデータを指定してください。また複製の過程でファ
|
||||
イル作成日時を書き換えます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool DuplicateImage(
|
||||
const ImageDbRecordLink& rLinkSrc,
|
||||
StorageType eStoTypeDst, ImageDbRecordLink* pLinkDst,
|
||||
Result& rResultSrc, Result& rResultDst);
|
||||
bool DuplicateImage(
|
||||
const ImageDbRecordLink& rLinkSrc,
|
||||
void* pSrcData, std::size_t nSrcDataSize,
|
||||
StorageType eStoTypeDst, ImageDbRecordLink* pLinkDst,
|
||||
Result& rResultSrc, Result& rResultDst);
|
||||
//@}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// 検索関連
|
||||
//------------------------------------------------------------------------
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索オブジェクトを生成する
|
||||
@param[in] rSearch 検索オブジェクト
|
||||
-----------------------------------------------------------------------*/
|
||||
void CreateSearchObject(ImageDbSearchObject& rSearch);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// レコード関連
|
||||
//------------------------------------------------------------------------
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコードリンクからレコードを取得する
|
||||
@param[in] rLink レコードリンク
|
||||
@return レコード
|
||||
@details
|
||||
レコードが見つからなかった場合はヌルを返します。
|
||||
戻り値のレコードはrLinkのレコードの種類に応じてPictureDbRecordまたは
|
||||
MovieDbRecordクラスにダウンキャスト可能です。
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageDbRecord* FindRecord(const ImageDbRecordLink& rLink) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコードパラメータを取得する
|
||||
@param[in] rLink 対象の映像情報のレコード
|
||||
@param[out] rRecParam 取得したレコードパラメータ
|
||||
-----------------------------------------------------------------------*/
|
||||
Result GetRecordParam(
|
||||
const ImageDbRecordLink& rLink, ImageDbRecordParam& rRecParam) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の妥当性情報を取得する
|
||||
@param[in] rLink 対象の映像情報のレコード
|
||||
@param[out] rValidityStateTblRec 取得した妥当性情報
|
||||
@details
|
||||
このメソッドで取得できる情報は、FindRecord()で取得したImageDbRecordの
|
||||
GetValidityStateTableRecord()の情報と同じものです。
|
||||
無効な映像情報に対して取得を行った場合はエラーを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result GetRecordValidityState(
|
||||
const ImageDbRecordLink& rLink,
|
||||
ValidityStateTableRecord& rValidityStateTblRec) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の妥当性情報を設定する
|
||||
@param[in] rLink 対象の映像情報のレコード
|
||||
@param[in] rValidityStateTblRec 設定する妥当性情報
|
||||
@details
|
||||
無効な映像情報に対して設定を行った場合はエラーを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result SetRecordValidityState(
|
||||
const ImageDbRecordLink& rLink,
|
||||
const ValidityStateTableRecord& rValidityStateTblRec);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// コレクター関連
|
||||
//------------------------------------------------------------------------
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像コレクターオブジェクトを生成する
|
||||
@param[in,out] rCollector 映像コレクターオブジェクト
|
||||
@param[in] eStoType 対象ストレージ
|
||||
-----------------------------------------------------------------------*/
|
||||
void CreateImageCollector(ImageCollector& rCollector, StorageType eStoType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像コレクターの内容をデータベースに反映する
|
||||
@param[in,out] rCollector 映像コレクターオブジェクト
|
||||
@details
|
||||
本関数はStopProcess()で処理を中止することができます。
|
||||
中止した場合はResultErrorStoppedを返し、対象データベースは修復処理が必要
|
||||
な状態となります(IsNeedRestore()がtrue)。そのため中止後に続けてデータ
|
||||
ベースを利用したい場合は、修復や再読み込み等を行い復元する必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result ReflectImageCollector(const ImageCollector& rCollector);
|
||||
|
||||
private:
|
||||
// シングルトン
|
||||
ImageDatabase();
|
||||
virtual ~ImageDatabase();
|
||||
|
||||
// 中止要求関連
|
||||
bool IsRequestStop() const;
|
||||
void ResetRequestStop();
|
||||
|
||||
// 映像データベース関連
|
||||
bool IsAvailableDatabase(StorageType eStoType) const;
|
||||
bool GetFileDatabaseSaveCount(
|
||||
u32& rSaveCnt, StorageType eStoType) const;
|
||||
Result UpdateNewerDatabase(StorageType eStoType);
|
||||
|
||||
// 復元必要フラグ関連
|
||||
void SetNeedRestore(StorageType eStoType);
|
||||
void ResetNeedRestore(StorageType eStoType);
|
||||
|
||||
// 管理テーブル関連
|
||||
Result SaveDatabase(StorageType eStoType);
|
||||
void ResetTable(StorageType eStoType);
|
||||
Result ReadPictureDatabase(StorageType eStoType, bool bTwlCompatible);
|
||||
Result WritePictureDatabase(StorageType eStoType, bool bTwlCompatible, bool bInvalidCrc=false);
|
||||
|
||||
// TWL写真管理とCTR管理情報のつじつま合わせ
|
||||
Result SyncPictureDatabaseWithTwl(StorageType eStoType);
|
||||
Result SortPictureDatabaseCtrAndTwl(StorageType eStoType);
|
||||
Result SyncPictureDatabaseDelSizeZero(StorageType eStoType);
|
||||
Result SyncPictureDatabaseCore(StorageType eStoType);
|
||||
|
||||
// レコード関連
|
||||
ImageDbRecord* FindRecordMutable(const ImageDbRecordLink& rLink){
|
||||
return const_cast<ImageDbRecord*>(static_cast<const ImageDatabase&>(*this).FindRecord(rLink)); }
|
||||
|
||||
Result CreateRecordLink(
|
||||
ImageDbRecordLink& rLink,
|
||||
StorageType eStoType, const DateTimeSeconds& rCreateSeconds, ImageKind eImgKind,
|
||||
const ImageDbRecordParam& rRecParam, s64 nImgDataSize1);
|
||||
Result CreateRecordLinkByIndexInfo(
|
||||
ImageDbRecordLink& rLink,
|
||||
StorageType eStoType, const DateTimeSeconds& rCreateSeconds, ImageKind eImgKind,
|
||||
const ImageDbRecordParam& rRecParam, s64 nImageSize, const IndexInfo& rIdxInfo);
|
||||
Result CreateRecordLinkByImageInfo(
|
||||
ImageDbRecordLink& rLink, StorageType eStoType,
|
||||
const ImageDbRecordParam& rRecParam, s64 nImageSize, const ImageInfo& rImgInfo);
|
||||
Result UnregisterRecord(const ImageDbRecordLink& rLink);
|
||||
Result UnregisterRecord(const ImageDbRecordLink& rLink, ImageDbRecord& rImgRec);
|
||||
Result UnregisterRecord(StorageType eStoType, int nRecIndex, ImageDbRecord& rImgRec);
|
||||
|
||||
void InsertRecordLinkList(
|
||||
RecordLinkList& rLinkList, const ImageDbRecordLink& rLink) const;
|
||||
std::size_t FindRecordLinkListInsertPos(
|
||||
const RecordLinkList& rLinkList, const ImageDbRecordLink& rLink) const;
|
||||
void InsertValidPictureRecordToList(
|
||||
StorageType eStoType, RecordLinkList& rLinkList);
|
||||
|
||||
static void StoreImageDbRecordFromParam(
|
||||
ImageDbRecord& rImgRec,
|
||||
const ImageDbRecordParam& rRecParam, ImageKind eImgKind);
|
||||
static void StorePictureDbRecordFromParam(
|
||||
PictureDbRecord& rPicRec,
|
||||
const ImageDbRecordParam & rRecParam, ImageKind eImgKind);
|
||||
|
||||
// 映像関連
|
||||
Result RegisterImage(
|
||||
StorageType eStoType, ImageKind eImgKind,
|
||||
const void* pImgData1, std::size_t nImgDataSize1,
|
||||
const void* pImgData2, std::size_t nImgDataSize2,
|
||||
const ImageDbRecordParam& rRecParam,
|
||||
bool bSave,
|
||||
const IndexInfo* pIdxInfo = 0,
|
||||
ImageDbRecordLink* pLink = 0);
|
||||
|
||||
// コレクター関連
|
||||
bool RegisterNewPictureFromImageCollector(
|
||||
StorageType eStoType, const ImageCollectionTableRecord& rColRec, bool bValidate);
|
||||
|
||||
static void SetImageCollectionTableRecordByExistence(
|
||||
ImageCollectionTableRecord& rColTblRec, const ImageInfo& rImgInfo);
|
||||
|
||||
static bool CompImageInfoFileStr(
|
||||
const ImageInfo& rImgInfo,
|
||||
const wchar_t* pDirName, const wchar_t* pFileName, const wchar_t* pExt);
|
||||
|
||||
void ReflectImageCollectorPictureLost(const ImageCollector& rCollector);
|
||||
void ReflectImageCollectorPictureNew(const ImageCollector& rCollector);
|
||||
void ReflectImageCollectorPictureChange(const ImageCollector& rCollector);
|
||||
|
||||
private:
|
||||
// 映像データベース初期化済みフラグ
|
||||
bool m_bInitialized;
|
||||
|
||||
// 処理中止要求
|
||||
volatile bool m_bReqStop;
|
||||
|
||||
// 復元必要フラグ
|
||||
bool m_bNeedRestoreFlag[StorageTypeNum];
|
||||
|
||||
// データベース
|
||||
PictureDatabase m_PictDb[StorageTypeNum];
|
||||
|
||||
// NAND/SD合わせて現在管理しているデータのレコードリンクのリスト(日付順でソート済み)
|
||||
RecordLinkList m_lRecordLinkList;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DATABASE_H_
|
||||
@ -0,0 +1,220 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbAllocator.h
|
||||
|
||||
アロケータ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_ALLOCATOR_H_
|
||||
#define IMAGE_DB_ALLOCATOR_H_
|
||||
|
||||
#include <limits>
|
||||
#include <nn/types.h>
|
||||
#include <nn/fnd.h>
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
class Allocator;
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ライブラリが使用するアロケータを取得する
|
||||
*---------------------------------------------------------------------------*/
|
||||
Allocator* GetAllocator();
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ライブラリが使用する画像ファイル用アロケータを取得する
|
||||
@details
|
||||
このアロケータは画像ファイル読み書き時に使用されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Allocator* GetFileAllocator();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ライブラリが使用するアロケータを設定する
|
||||
*---------------------------------------------------------------------------*/
|
||||
void SetAllocator(nn::fnd::IAllocator* pAllocator, nn::fnd::IAllocator* pFileAllocator);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ライブラリが使用するアロケータを未設定状態にする
|
||||
*---------------------------------------------------------------------------*/
|
||||
void ResetAllocator();
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ImageDbアロケータ
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class Allocator : private nn::util::NonCopyable<Allocator>
|
||||
{
|
||||
public:
|
||||
static const int c_nDefaultAlignment = 4;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
Allocator() : m_pAllocator(0){}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~Allocator(){ Release(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アロケータが初期化されているかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const{ return (0 != m_pAllocator); }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アロケータを初期化する
|
||||
@param[in] rAllocator 実際に使用するアロケータ
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(nn::fnd::IAllocator& rAllocator){
|
||||
NN_ASSERT(!IsInitialized());
|
||||
if(!IsInitialized()){
|
||||
m_pAllocator = &rAllocator;
|
||||
}
|
||||
}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アロケータを解放するする
|
||||
-----------------------------------------------------------------------*/
|
||||
void Release(){ m_pAllocator = 0; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief メモリを確保する
|
||||
@param[in] nSize 確保サイズ(バイト単位)
|
||||
@param[in] nAligment 確保するメモリのアライメント
|
||||
@return 確保したメモリ
|
||||
-----------------------------------------------------------------------*/
|
||||
void* Alloc(size_t nSize, int nAligment=c_nDefaultAlignment){
|
||||
NN_NULL_ASSERT(m_pAllocator);
|
||||
return m_pAllocator->Allocate(nSize, static_cast<u8>(nAligment));
|
||||
}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief オブジェクトを確保しコンストラクタを呼び出す
|
||||
@param[in] nSize 確保するオブジェクト数
|
||||
@param[in] nAligment 確保するメモリのアライメント
|
||||
@return 確保したオブジェクト
|
||||
-----------------------------------------------------------------------*/
|
||||
template<typename TObject>
|
||||
TObject* AllocAndConstruct(std::size_t nSize, int nAligment=c_nDefaultAlignment){
|
||||
TObject* pObj = static_cast<TObject*>(Alloc(sizeof(TObject)*nSize, nAligment));
|
||||
if(0 != pObj){
|
||||
for(std::size_t i = 0; i < nSize; ++i){
|
||||
Construct(&pObj[i]);
|
||||
}
|
||||
}
|
||||
return pObj;
|
||||
}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief メモリを解放する
|
||||
@param[in] pAddr 解放するメモリ
|
||||
-----------------------------------------------------------------------*/
|
||||
void Free(void* pAddr){
|
||||
NN_NULL_ASSERT(m_pAllocator);
|
||||
m_pAllocator->Free(pAddr);
|
||||
}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタを呼び出しオブジェクトを解放する
|
||||
@param[in] pObj 解放するオブジェクト
|
||||
@param[in] nSize 解放するオブジェクト数
|
||||
-----------------------------------------------------------------------*/
|
||||
template<typename TObject>
|
||||
void DestructAndFree(TObject* pObj, std::size_t nSize){
|
||||
if(0 != pObj){
|
||||
for(std::size_t i = 0; i < nSize; ++i){
|
||||
Destruct(&pObj[i]);
|
||||
}
|
||||
Free(pObj);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename TObject>
|
||||
void Construct(TObject* pObj){ new(static_cast<void*>(pObj)) TObject; }
|
||||
|
||||
template<typename TObject>
|
||||
void Destruct(TObject* pObj){ pObj->~TObject(); }
|
||||
|
||||
private:
|
||||
nn::fnd::IAllocator* m_pAllocator;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief STL関連で使用するアロケータ
|
||||
@details
|
||||
GetAllocator()からメモリを使用するアロケータです。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
template<typename T>
|
||||
class XAllocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T value_type;
|
||||
|
||||
template <class U> struct rebind { typedef XAllocator<U> other; };
|
||||
|
||||
XAllocator() throw(){}
|
||||
XAllocator(const XAllocator&) throw(){}
|
||||
template <typename U> XAllocator(const XAllocator<U>&) throw(){}
|
||||
|
||||
~XAllocator() throw(){}
|
||||
|
||||
pointer address(reference value) const { return &value; }
|
||||
const_pointer address(const_reference value) const { return &value; }
|
||||
|
||||
pointer allocate(size_type num, void* hint = 0){
|
||||
(void)(&hint);
|
||||
return static_cast<pointer>(GetAllocator()->Alloc(num * sizeof(T), 32));
|
||||
}
|
||||
|
||||
void deallocate(pointer p, size_type num){
|
||||
(void)(&num);
|
||||
GetAllocator()->Free(static_cast<pointer>(p));
|
||||
}
|
||||
|
||||
size_type max_size() const throw(){
|
||||
return std::numeric_limits<size_t>::max() / sizeof(T);
|
||||
}
|
||||
|
||||
void construct(pointer p, const T& value) { new( (void*)p ) T(value); }
|
||||
|
||||
void destroy(pointer p){ p->~T(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
bool operator==(const XAllocator<T>&, const XAllocator<T>&){ return true; }
|
||||
template<typename T>
|
||||
bool operator!=(const XAllocator<T>&, const XAllocator<T>&){ return false; }
|
||||
|
||||
template<>
|
||||
class XAllocator<void>
|
||||
{
|
||||
public:
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
template<class U> struct rebind { typedef XAllocator<U> other; };
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_ALLOCATOR_H_
|
||||
@ -0,0 +1,328 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbArchiveMounter.h
|
||||
|
||||
特定のアーカイブをマウントする
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_ARCHIVE_MOUNTER_H_
|
||||
#define IMAGE_DB_ARCHIVE_MOUNTER_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbSingleton.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief アーカイブマウントクラス(インターフェース)
|
||||
*---------------------------------------------------------------------------*/
|
||||
class ArchiveMounter
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief マウントする
|
||||
@return マウントに成功した場合はtrue
|
||||
@details
|
||||
既にマウント中の場合はアサートが発生して何もせずに終了します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Mount() = 0;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アンマウントする
|
||||
@details
|
||||
既にアンマウント中の場合は何もせずに終了します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Unmount() = 0;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief マウントしているかチェックする
|
||||
@return マウントしている場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool IsMount() const = 0;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 空きサイズを取得する
|
||||
@return 空きサイズ(バイト単位)
|
||||
@details
|
||||
マウントされていないなどでサイズが取得できない場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual s64 GetFreeSize() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ArchiveMounter() = 0;
|
||||
};
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief SDカード領域マウントクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class SdArchiveMounter : public Singleton<SdArchiveMounter>
|
||||
, public ArchiveMounter
|
||||
, private nn::util::NonCopyable<SdArchiveMounter>
|
||||
{
|
||||
friend class Allocator;
|
||||
|
||||
public:
|
||||
// SDカードのアーカイブ名 例:"$phtsd"
|
||||
static const char* c_pArchiveName;
|
||||
static const wchar_t* c_pWArchiveName;
|
||||
// SDカードのアーカイブ名の文字数
|
||||
static const int c_nArchiveNameLength = 6;
|
||||
|
||||
// SDカードのコロンつきアーカイブ名 例:"$phtsd:"
|
||||
static const char* c_pArchiveNameWithColon;
|
||||
static const wchar_t* c_pWArchiveNameWithColon;
|
||||
// SDカードのコロンつきアーカイブ名の文字数
|
||||
static const int c_nArchiveNameLengthWithColon = c_nArchiveNameLength + 1;
|
||||
|
||||
// SDカードの仮想アーカイブ名 例:"$_sdmc"
|
||||
static const char* c_pVirtualArchiveName;
|
||||
static const wchar_t* c_pWVirtualArchiveName;
|
||||
// SDカードの仮想アーカイブ名の文字数
|
||||
static const int c_nVirtualArchiveNameLength = 6;
|
||||
|
||||
// SDカードのコロンつき仮想アーカイブ名 例:"$_sdmc:"
|
||||
static const char* c_pVirtualArchiveNameWithColon;
|
||||
static const wchar_t* c_pWVirtualArchiveNameWithColon;
|
||||
// SDカードのコロンつき仮想アーカイブ名の文字数
|
||||
static const int c_nVirtualArchiveNameLengthWithColon = c_nVirtualArchiveNameLength + 1;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカード領域をマウントする
|
||||
@return マウントに成功した場合はtrue
|
||||
@details
|
||||
既にマウントされている場合は何もせずにfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Mount();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカード領域をアンマウントする
|
||||
@details
|
||||
既にアンマウント中の場合は何もせずに終了します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Unmount();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカード領域をマウントしているかチェックする
|
||||
@return マウントしている場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool IsMount() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカード領域の空きサイズを取得する
|
||||
@return 空きサイズ(バイト単位)
|
||||
@details
|
||||
マウントされていない、SDカードが抜けているなどでサイズが取得できない場
|
||||
合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual s64 GetFreeSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカード領域の総容量サイズを取得する
|
||||
@return 総容量サイズ(バイト単位)
|
||||
@details
|
||||
マウントされていない、SDカードが抜けているなどでサイズが取得できない場
|
||||
合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
s64 GetTotalSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカードが挿入されているかチェックする
|
||||
@return 挿入されている場合はtrue
|
||||
@details
|
||||
この関数は高負荷のため仕様の際は気をつけてください。
|
||||
-----------------------------------------------------------------------*/
|
||||
static bool IsInsert();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカードが書き込み可能かチェックする
|
||||
@return 可能な場合は場合はtrue
|
||||
@details
|
||||
SDカードが挿入され、ライトプロテクトスイッチがOffになっていれば書き込み
|
||||
可能となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
static bool IsWritable();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカードが壊れているかチェックする
|
||||
@return 壊れている場合は場合はtrue
|
||||
@details
|
||||
SDカードをマウントした時のメディアの状態となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsBadMedia() const;
|
||||
|
||||
private:
|
||||
// シングルトン
|
||||
SdArchiveMounter();
|
||||
virtual ~SdArchiveMounter();
|
||||
|
||||
private:
|
||||
bool m_bMount;
|
||||
bool m_bIsBadMedia;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief CTR-NAND領域マウントクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class CtrNandArchiveMounter : public Singleton<CtrNandArchiveMounter>
|
||||
, public ArchiveMounter
|
||||
, private nn::util::NonCopyable<CtrNandArchiveMounter>
|
||||
{
|
||||
friend class Allocator;
|
||||
|
||||
public:
|
||||
// CTR-NANDのアーカイブ名 "$_phtsh"
|
||||
static const char* c_pArchiveName;
|
||||
static const wchar_t* c_pWArchiveName;
|
||||
// CTR-NANDのアーカイブ名の文字数
|
||||
static const int c_nArchiveNameLength = 4;
|
||||
|
||||
// CTR-NANDのコロンつきアーカイブ名 例:"$_phtsh:"
|
||||
static const char* c_pArchiveNameWithColon;
|
||||
static const wchar_t* c_pWArchiveNameWithColon;
|
||||
// CTR-NANDのコロンつきアーカイブ名の文字数
|
||||
static const int c_nArchiveNameLengthWithColon = c_nArchiveNameLength + 1;
|
||||
|
||||
static const bit32 c_nSharedExtSaveDataId = 0xf0000001;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CTR-NAND領域をマウントする
|
||||
@return マウントに成功した場合はtrue
|
||||
@details
|
||||
既にマウントされている場合は何もせずにfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Mount();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CTR-NAND領域をアンマウントする
|
||||
@details
|
||||
既にアンマウント中の場合は何もせずに終了します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Unmount();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CTR-NAND領域をマウントしているかチェックする
|
||||
@return マウントしている場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool IsMount() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CTR-NAND領域の空きサイズを取得する
|
||||
@return 空きサイズ(バイト単位)
|
||||
@details
|
||||
マウントされていないなどでサイズが取得できない場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual s64 GetFreeSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CTR-NAND領域の空きブロック数を求める
|
||||
@param[out] rTotalBlock 総ブロック数
|
||||
@param[out] rLeftBlock 空きブロック数
|
||||
@param[out] rBlockSize ブロックサイズ(Byte)
|
||||
@return 取得できた場合はtrue
|
||||
@details
|
||||
マウントされていないなどで取得できない場合はfalseを返します。その時の引
|
||||
数の内容は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetSharedExtSaveDataBlockSize(
|
||||
s64& rTotalBlock, s64& rLeftBlock, s32& rBlockSize) const;
|
||||
|
||||
private:
|
||||
// シングルトン
|
||||
CtrNandArchiveMounter();
|
||||
virtual ~CtrNandArchiveMounter();
|
||||
|
||||
private:
|
||||
bool m_bMount;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief TWL-NAND領域マウントクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class TwlNandArchiveMounter : public Singleton<TwlNandArchiveMounter>
|
||||
, public ArchiveMounter
|
||||
, private nn::util::NonCopyable<TwlNandArchiveMounter>
|
||||
{
|
||||
friend class Allocator;
|
||||
|
||||
public:
|
||||
// TWL-NANDのアーカイブ名 "twlp"
|
||||
static const char* c_pArchiveName;
|
||||
static const wchar_t* c_pWArchiveName;
|
||||
// TWL-NANDのアーカイブ名の文字数
|
||||
static const int c_nArchiveNameLength = 7;
|
||||
|
||||
// TWL-NANDのコロンつきアーカイブ名 例:"twlp:"
|
||||
static const char* c_pArchiveNameWithColon;
|
||||
static const wchar_t* c_pWArchiveNameWithColon;
|
||||
// TWL-NANDのコロンつきアーカイブ名の文字数
|
||||
static const int c_nArchiveNameLengthWithColon = c_nArchiveNameLength + 1;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief TWL-NAND領域をマウントする
|
||||
@return マウントに成功した場合はtrue
|
||||
@details
|
||||
既にマウントされている場合は何もせずにfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Mount();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief TWL-NAND領域をアンマウントする
|
||||
@details
|
||||
既にアンマウント中の場合は何もせずに終了します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Unmount();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief TWL-NAND領域をマウントしているかチェックする
|
||||
@return マウントしている場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool IsMount() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief TWL-NAND領域の空きサイズを取得する
|
||||
@return 空きサイズ(バイト単位)
|
||||
@details
|
||||
マウントされていないなどでサイズが取得できない場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual s64 GetFreeSize() const;
|
||||
|
||||
private:
|
||||
// シングルトン
|
||||
TwlNandArchiveMounter();
|
||||
virtual ~TwlNandArchiveMounter();
|
||||
|
||||
private:
|
||||
bool m_bMount;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_ARCHIVE_MOUNTER_H_
|
||||
325
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbConst.h
Normal file
325
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbConst.h
Normal file
@ -0,0 +1,325 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbConst.h
|
||||
|
||||
定数定義
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_CONST_H_
|
||||
#define IMAGE_DB_CONST_H_
|
||||
|
||||
#include "ImageDbDebug.h"
|
||||
#include "ImageDbTypes.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 定数定義クラス
|
||||
@details
|
||||
インスタンス化不可
|
||||
*---------------------------------------------------------------------------*/
|
||||
class Const
|
||||
{
|
||||
Const();
|
||||
Const(const Const&);
|
||||
|
||||
public:
|
||||
// PNOTEのタイトルユニークID(20bitの値)
|
||||
static const u32 c_nPNoteTitleUniqueId = 0x00204;
|
||||
|
||||
// PNOTEのExifのソフトウェア名(タイトルユニークIDの文字列)
|
||||
static const char* c_pPNoteExifSoftware;
|
||||
|
||||
|
||||
//! ドライブ名の最大文字数(例:sdmc:/)
|
||||
#if defined(IMG_DB_EMULATE_CTR_NAND_ON_SD) || defined(IMG_DB_EMULATE_TWL_NAND_ON_SD)
|
||||
// NANDをSDでエミュレートしているため多め
|
||||
static const int c_nMaxDriveNameLength = 20;
|
||||
#else
|
||||
static const int c_nMaxDriveNameLength = 10;
|
||||
#endif
|
||||
|
||||
|
||||
//! NANDプライベート領域のディレクトリ(例:photo/Nintendo 3DS/Private/00020400)
|
||||
static const wchar_t* c_pWPrivateDirectoryNand;
|
||||
static const char* c_pPrivateDirectoryNand;
|
||||
//! NANDプライベート領域のディレクトリの文字数
|
||||
static const int c_nPrivateDirectoryLengthNand = 35;
|
||||
|
||||
//! SDプライベート領域のディレクトリ(例:Nintendo 3DS/Private/00020400)
|
||||
static const wchar_t* c_pWPrivateDirectorySd;
|
||||
static const char* c_pPrivateDirectorySd;
|
||||
//! SDプライベート領域のディレクトリの文字数
|
||||
static const int c_nPrivateDirectoryLengthSd = 29;
|
||||
|
||||
//! CTRプライベート領域のディレクトリ
|
||||
static const wchar_t* c_pWPrivateDirectoryCtr[StorageTypeNum];
|
||||
static const char* c_pPrivateDirectoryCtr[StorageTypeNum];
|
||||
//! CTRプライベート領域のディレクトリの文字数
|
||||
static const int c_nPrivateDirectoryLengthCtr[StorageTypeNum];
|
||||
//! CTRプライベート領域のディレクトリの最大文字数
|
||||
static const int c_nMaxPrivateDirectoryLengthCtr = (c_nPrivateDirectoryLengthNand < c_nPrivateDirectoryLengthSd) ?
|
||||
c_nPrivateDirectoryLengthSd :
|
||||
c_nPrivateDirectoryLengthNand;
|
||||
|
||||
//! レガシープライベート領域のディレクトリ(例:photo/private/ds/app/484E494A)
|
||||
static const wchar_t* c_pWLegacyPrivateDirectory;
|
||||
static const char* c_pLegacyPrivateDirectory;
|
||||
//! レガシープライベート領域のディレクトリの文字数
|
||||
static const int c_nLegacyPrivateDirectoryLength = 29;
|
||||
|
||||
//! プライベート領域のディレクトリの最大文字数
|
||||
static const int c_nMaxPrivateDirectoryLength = (c_nMaxPrivateDirectoryLengthCtr < c_nLegacyPrivateDirectoryLength) ?
|
||||
c_nLegacyPrivateDirectoryLength :
|
||||
c_nMaxPrivateDirectoryLengthCtr;
|
||||
|
||||
|
||||
//! レガシー管理テーブルのファイル名(例:pit.bin)
|
||||
static const wchar_t* c_pWLegacyTableFileName;
|
||||
static const char* c_pLegacyTableFileName;
|
||||
//! レガシー管理テーブルのファイル名の文字数
|
||||
static const int c_nLegacyTableFileNameLength = 7;
|
||||
//! 写真管理テーブルのファイル名(例:phtcache.bin)
|
||||
static const wchar_t* c_pWPictureTableFileName;
|
||||
static const char* c_pPictureTableFileName;
|
||||
//! 写真管理テーブルのファイル名の文字数
|
||||
static const int c_nPictureTableFileNameLength = 12;
|
||||
//! 管理テーブルのファイル名の最大文字数
|
||||
static const int c_nMaxTableFileNameLength = (c_nLegacyTableFileNameLength < c_nPictureTableFileNameLength) ?
|
||||
c_nPictureTableFileNameLength :
|
||||
c_nLegacyTableFileNameLength;
|
||||
|
||||
|
||||
//! 管理テーブルのファイルフルパスの最大文字数(例:sdmc:/private/ds/app/484E494A/pit.binの文字数)
|
||||
static const int c_nMaxTableFileFullPathLength = c_nMaxDriveNameLength // sdmc:/
|
||||
+ c_nMaxPrivateDirectoryLength // private/ds/app/484E494A
|
||||
+ 1 // /
|
||||
+ c_nMaxTableFileNameLength; // pit.bin
|
||||
|
||||
|
||||
//! NAND写真のルートディレクトリ(例:photo/DCIM)
|
||||
static const wchar_t* c_pWPictureRootDirectoryNand;
|
||||
static const char* c_pPictureRootDirectoryNand;
|
||||
//! NAND写真のルートディレクトリの文字数
|
||||
static const int c_nPictureRootDirectoryLengthNand = 10;
|
||||
//! SD写真のルートディレクトリ(例:DCIM)
|
||||
static const wchar_t* c_pWPictureRootDirectorySd;
|
||||
static const char* c_pPictureRootDirectorySd;
|
||||
//! SD写真のルートディレクトリの文字数
|
||||
static const int c_nPictureRootDirectoryLengthSd = 4;
|
||||
//! 写真のルートディレクトリの配列
|
||||
static const wchar_t* c_pWPictureRootDirectorys[StorageTypeNum];
|
||||
static const char* c_pPictureRootDirectorys[StorageTypeNum];
|
||||
//! 写真のルートディレクトリの文字数の配列
|
||||
static const int c_nPictureRootDirectorysLength[StorageTypeNum];
|
||||
//! 写真のルートディレクトリの最大文字数
|
||||
static const int c_nMaxPictureRootDirectorysLength = (c_nPictureRootDirectoryLengthNand < c_nPictureRootDirectoryLengthSd) ?
|
||||
c_nPictureRootDirectoryLengthSd :
|
||||
c_nPictureRootDirectoryLengthNand;
|
||||
|
||||
//! 映像のルートディレクトリの配列
|
||||
static const wchar_t* c_pWRootDirectorys[StorageTypeNum];
|
||||
static const char* c_pRootDirectorys[StorageTypeNum];
|
||||
//! 映像のルートディレクトリの文字数の配列
|
||||
static const int c_nRootDirectorysLength[StorageTypeNum];
|
||||
//! 映像のルートディレクトリの最大文字数
|
||||
static const int c_nMaxRootDirectorysLength = c_nMaxPictureRootDirectorysLength;
|
||||
|
||||
|
||||
//! 映像ディレクトリの文字数(例:100NIN02 DCFではピッタリ8文字がルール)
|
||||
static const int c_nImageDirectoryLength = 8; // 変更不可
|
||||
//! 映像ディレクトリの番号部分の桁数
|
||||
static const int c_nImageDirectoryNumberDigit = 3; // 変更不可
|
||||
//! 映像ディレクトリのポストフィックスのコア名(例:NIN)
|
||||
static const wchar_t* c_pWImageDirectoryNamePostfixCore;
|
||||
static const char* c_pImageDirectoryNamePostfixCore;
|
||||
//! 映像ディレクトリのポストフィックスのコア名の文字数
|
||||
static const int c_nImageDirectoryNamePostfixCoreLength = 3; // 変更不可
|
||||
//! 映像ディレクトリのポストフィックス(例:NIN03)
|
||||
static const wchar_t* c_pWImageDirectoryNamePostfix;
|
||||
static const char* c_pImageDirectoryNamePostfix;
|
||||
//! 映像ディレクトリのポストフィックスの後ろの数字の値
|
||||
static const int c_nImageDirectoryNamePostfixNoValue = 3;
|
||||
//! レガシー映像ディレクトリのポストフィックス(例:NIN02)
|
||||
static const wchar_t* c_pWLegacyImageDirectoryNamePostfix;
|
||||
static const char* c_pLegacyImageDirectoryNamePostfix;
|
||||
//! レガシー映像ディレクトリのポストフィックスの後ろの数字の値
|
||||
static const int c_nLegacyImageDirectoryNamePostfixNoValue = 2;
|
||||
//! 映像ディレクトリのポストフィックスの文字数
|
||||
static const int c_nImageDirectoryNamePostfixLength = 5; // 変更不可
|
||||
|
||||
|
||||
//! 映像データのファイル名の文字数(DCFではピッタリ8文字がルール)
|
||||
static const int c_nImageFileNameLength = 8; // 変更不可
|
||||
//! 映像データのファイル名のプレフィックス(例:HNI_)
|
||||
static const wchar_t* c_pWImageFileNamePrefix;
|
||||
static const char* c_pImageFileNamePrefix;
|
||||
//! 映像データのファイル名のプレフィックスの文字数
|
||||
static const int c_nImageFileNamePrefixLength = 4; // 変更不可
|
||||
//! 映像データのファイル名の番号部分の桁数
|
||||
static const int c_nImageFileNameNumberDigit = 4; // 変更不可
|
||||
|
||||
//! 拡張子の最大文字数(ドットは含まない。DCFでは文字数規定なし)
|
||||
static const int c_nMaxExtLength = 4;
|
||||
//! 映像データの拡張子
|
||||
static const wchar_t* c_pWImageFileExt[ImageKindNum];
|
||||
static const char* c_pImageFileExt[ImageKindNum];
|
||||
//! 映像データの拡張子の文字数
|
||||
static const int c_nImageFileExtLength[ImageKindNum];
|
||||
|
||||
|
||||
//! 映像のルートディレクトリパスの最大文字数(例:sdmc:/DCIM)
|
||||
static const int c_nMaxRootDirectoryPathLength = c_nMaxDriveNameLength // sdmc:/
|
||||
+ c_nMaxRootDirectorysLength; // DCIM
|
||||
//! 映像ディレクトリパスの最大文字数(例:sdmc:/DCIM/100NIN02)
|
||||
static const int c_nMaxImageDirectoryPathLength = c_nMaxRootDirectoryPathLength // sdmc:/DCIM
|
||||
+ 1 // /
|
||||
+ c_nImageDirectoryLength; // 100NIN02
|
||||
|
||||
//! 映像データのファイル名+拡張子の最大文字数(例:HNI_0001.JPG)
|
||||
static const int c_nMaxImageFileNameWithExtLength = c_nImageFileNameLength // HNI_0001
|
||||
+ 1 // .
|
||||
+ c_nMaxExtLength; // JPG
|
||||
//! 映像データのファイルパスの最大文字数(例:100NIN02/HNI_0001.JPGの文字数)
|
||||
static const int c_nMaxImageFilePathLength = c_nImageDirectoryLength // 100NIN02
|
||||
+ 1 // /
|
||||
+ c_nMaxImageFileNameWithExtLength; // HNI_0001.JPG
|
||||
//! 映像データのファイルフルパスの最大文字数(例:sdmc:/DCIM/100NIN02/HNI_0001.JPGの文字数)
|
||||
static const int c_nMaxImageFileFullPathLength = c_nMaxRootDirectoryPathLength // sdmc:/DCIM
|
||||
+ 1 // /
|
||||
+ c_nMaxImageFilePathLength; // 100NIN02/HNI_0001.JPG
|
||||
|
||||
//! TWLで扱える写真枚数
|
||||
//@{
|
||||
static const int c_nLegacyPictureRecordNumNand = 500; // 変更不可
|
||||
static const int c_nLegacyPictureRecordNumSd = 3000; // 変更不可
|
||||
//@}
|
||||
|
||||
//! NANDで扱える映像数
|
||||
//@{
|
||||
static const int c_nPictureRecordNumNand = 500; // 変更可
|
||||
static const int c_nAllRecordNumNand = c_nPictureRecordNumNand;
|
||||
//@}
|
||||
|
||||
//! SDカードで扱える映像数
|
||||
//@{
|
||||
static const int c_nPictureRecordNumSd = 3000; // 変更可
|
||||
static const int c_nAllRecordNumSd = c_nPictureRecordNumSd;
|
||||
//@}
|
||||
|
||||
//! 全体で扱える映像数
|
||||
//@{
|
||||
static const int c_nPictureRecordNum = c_nPictureRecordNumNand + c_nPictureRecordNumSd;
|
||||
static const int c_nAllRecordNum = c_nPictureRecordNum;
|
||||
//@}
|
||||
|
||||
//! 扱える映像数を配列でアクセスするための定数
|
||||
static const int c_nRecordNumAry[StorageTypeNum];
|
||||
|
||||
|
||||
//! 顔情報の最大数
|
||||
static const int c_nMaxFaceInfoNum = 4;
|
||||
|
||||
/*!
|
||||
@details
|
||||
扱える映像ファイルの最大サイズ(バイト単位)
|
||||
エンコードしたJPEG/MPの最大サイズとなります。
|
||||
*/
|
||||
//@{
|
||||
static const std::size_t c_nMaxHandleTwlJpegSize = 200*1024-1; // TWLのJPEG
|
||||
static const std::size_t c_nMaxHandleJpegSize = 200*1024; // JPEG
|
||||
static const std::size_t c_nMaxHandleMpSize = 400*1024; // MP
|
||||
static const std::size_t c_nMaxHandleJpegInMJpegSize = c_nMaxHandleMpSize; // モーションJPEG内のJPEG
|
||||
//@}
|
||||
//! 扱える映像ファイルの最大サイズの配列
|
||||
static const std::size_t c_nMaxHandleImageSize[ImageKindNum];
|
||||
|
||||
/*!
|
||||
@details
|
||||
扱う映像ファイルの平均サイズ(バイト単位)
|
||||
エンコードしたJPEG/MPの平均的なサイズとなります。
|
||||
残り枚数のデフォルトの見積もり数は、このサイズが利用されます。
|
||||
*/
|
||||
//@{
|
||||
static const std::size_t c_nJpegDefaultQualityAvgImageSize = 80*1024; // TWLのときと一緒
|
||||
// MPOは150KBとして見積もりたいが、NANDのブロック消費数が想定の+4ブロックとなるため(38+4)*4K=168KBと設定する
|
||||
static const std::size_t c_nMpDefaultQualityAvgImageSize = 42*4*1024;
|
||||
//@}
|
||||
//! 扱う映像ファイルの平均サイズの配列
|
||||
static const std::size_t c_nDefaultQualityAvgImageSize[ImageKindNum];
|
||||
|
||||
|
||||
//! 読み込める映像ファイルのデフォルト最大サイズ(バイト単位)
|
||||
static const std::size_t c_nDefaultMaxReadImageFileSize = c_nMaxHandleMpSize; // MPと同じサイズまで
|
||||
|
||||
//! 一般的なディレクトリでの最大リード数
|
||||
static const int c_nMaxReadDirNumInGeneral = 1000;
|
||||
//! DCFの映像ディレクトリ(100NIN02~999NIN02)での最大リード数
|
||||
static const int c_nMaxReadDirNumInDcfDir = 1000;
|
||||
//! DCFの映像ファイル(HNI_0001.XXX~HNI_0100.XXX)での最大リード数
|
||||
static const int c_nMaxReadDirNumInDcfFile = c_nPictureRecordNumSd*2; //最大で扱える映像数に対となるデータを考慮した数
|
||||
|
||||
|
||||
//! 標準で扱う最大の画像サイズ
|
||||
//@{
|
||||
static const int c_nMaxStandardPictureWidth = 1024;
|
||||
static const int c_nMaxStandardPictureHeight = 768;
|
||||
//@}
|
||||
//! 標準で扱う最小の画像サイズ
|
||||
//@{
|
||||
static const int c_nMinStandardPictureWidth = 160;
|
||||
static const int c_nMinStandardPictureHeight = 120;
|
||||
//@}
|
||||
//! 標準で扱う画像の最大縮小レベル
|
||||
static const int c_nMaxStandardPictureShrinkLevel = 2;
|
||||
|
||||
//! 標準で扱う最大のサムネイル画像サイズ
|
||||
//@{
|
||||
static const int c_nMaxStandardThumbnailWidth = 320;
|
||||
static const int c_nMaxStandardThumbnailHeight = 240;
|
||||
//@}
|
||||
//! 標準で扱う最小のサムネイル画像サイズ
|
||||
//@{
|
||||
static const int c_nMinStandardThumbnailWidth = 0;
|
||||
static const int c_nMinStandardThumbnailHeight = 0;
|
||||
//@}
|
||||
//! 標準で扱うサムネイル画像の最大縮小レベル
|
||||
static const int c_nMaxStandardThumbnailShrinkLevel = 2;
|
||||
|
||||
//! 本画像からサムネイル作成できる最大の画像サイズ
|
||||
//@{
|
||||
static const int c_nMaxThumbnailFromPictureWidth = 256;
|
||||
static const int c_nMaxThumbnailFromPictureHeight = 192;
|
||||
//@}
|
||||
//! 本画像からサムネイル作成できる最小の画像サイズ
|
||||
//@{
|
||||
static const int c_nMinThumbnailFromPictureWidth = c_nMinStandardPictureWidth;
|
||||
static const int c_nMinThumbnailFromPictureHeight = c_nMinStandardPictureHeight;
|
||||
//@}
|
||||
//! 本画像からサムネイル作成できる画像の最大縮小レベル
|
||||
static const int c_nMaxThumbnailFromPictureShrinkLevel = 2;
|
||||
|
||||
|
||||
//! 動画の最大撮影時間(秒単位)
|
||||
static const int c_nMaxMovieRecordingTime = 600;
|
||||
|
||||
|
||||
// ImageDbが内部で利用しているutil::NmjPlayerConfigクラスのId(負数)
|
||||
enum NmjPlayerConfigId {
|
||||
NmjPlayerConfigIdDefault = -1,
|
||||
NmjPlayerConfigIdCollector = -2,
|
||||
NmjPlayerConfigIdReflectCollector = -3,
|
||||
NmjPlayerConfigIdSysNoteRw = -4
|
||||
};
|
||||
|
||||
// ImageDbが内部で利用しているutil::NmjPlayerConfigクラスのId(負数)
|
||||
enum NmjRecordingConfigId {
|
||||
NmjPlayerConfigIdEstimate = -1
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
|
||||
#endif // IMAGE_DB_CONST_H_
|
||||
127
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbCrc.h
Normal file
127
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbCrc.h
Normal file
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbCrc.h
|
||||
|
||||
CRC
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_CRC_H_
|
||||
#define IMAGE_DB_CRC_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/crypto.h>
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief CRC16クラス
|
||||
@details
|
||||
nn::crypto::HashContextBase設計にあわせたCRC16を求めるクラスです。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class Crc16Context : public nn::crypto::HashContextBase
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
Crc16Context();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~Crc16Context();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief オブジェクトの初期化処理
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Initialize();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief オブジェクトの完了処理
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Finalize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CRC値を与えられたデータで更新する
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void Update(const void* pData, size_t length);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CRCの長さを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual size_t GetHashLength() { return 2; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最終的なCRC計算結果を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual void GetHash(void* pOut);
|
||||
|
||||
private:
|
||||
static const int c_nTableElementNum = 256;
|
||||
|
||||
static const u32 c_nStandardPoly = 0xa001;
|
||||
static const u16 c_nInitHash = 0;
|
||||
|
||||
private:
|
||||
static void InitTable();
|
||||
|
||||
private:
|
||||
static bool m_bInitializedTable;
|
||||
static u16 m_nCrcTable[c_nTableElementNum];
|
||||
|
||||
bool m_bInitialized;
|
||||
u16 m_nHash;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief CRC16クラス
|
||||
@details
|
||||
Crc16Contextを気軽に使い捨て使用できるようにラップしたクラスです。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class Crc16
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] pData ハッシュ値を求めるデータ
|
||||
@param[in] nSize データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
Crc16();
|
||||
Crc16(const void* pData, std::size_t nSize);
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~Crc16();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CRC値を与えられたデータで更新する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Update(const void* pData, std::size_t nSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CRC値を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
u16 GetHash();
|
||||
|
||||
private:
|
||||
Crc16Context m_Ctx;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_CRC_H_
|
||||
@ -0,0 +1,212 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbDateTimeSeconds.h
|
||||
|
||||
経過秒数
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_DATE_TIME_SECONDS_H_
|
||||
#define IMAGE_DB_DATE_TIME_SECONDS_H_
|
||||
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/fnd.h>
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 経過秒数構造体(POD)
|
||||
@details
|
||||
2000/1/1 0時0分0秒を起点とした秒数で日時を扱います。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct DateTimeSeconds
|
||||
{
|
||||
public:
|
||||
s64 nSeconds;
|
||||
|
||||
public:
|
||||
//! 日時文字列の文字数
|
||||
static const int c_nDateTimeStringLength = 19;
|
||||
|
||||
//! 1日の秒数
|
||||
static const s64 c_nOneDaySeconds = 24*60*60;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最低の経過秒数を取得する
|
||||
@return 経過秒数
|
||||
@detail
|
||||
1900/1/1 0時0分0秒 の経過秒数です。
|
||||
-----------------------------------------------------------------------*/
|
||||
static DateTimeSeconds GetMinSeconds();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最大の経過秒数を取得する
|
||||
@return 経過秒数
|
||||
@detail
|
||||
2150/12/31 23時59分59秒 の経過秒数です。
|
||||
-----------------------------------------------------------------------*/
|
||||
static DateTimeSeconds GetMaxSeconds();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 無効な経過秒数を取得する
|
||||
@return 無効な経過秒数
|
||||
@details
|
||||
扱える数値の範囲内で最も小さい値となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
static s64 GetInvalidSeconds();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 無効な経過日数を取得する
|
||||
@return 無効な経過日数
|
||||
@details
|
||||
扱える数値の範囲内で最も小さい値となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
static int GetInvalidDays();
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@details
|
||||
2000/1/1 0時0分0秒に設定します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 無効状態で初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void InitializeInvalid();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 無効状態かチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInvalid() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 経過秒数値を取得/設定する
|
||||
@details
|
||||
2000/1/1 0時0分0秒を起点とした経過秒数をs64で取得/設定します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
s64 GetSeconds() const{ return nSeconds; }
|
||||
void SetSeconds(s64 nSeconds);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 経過日数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetDays() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 年月日変換用の経過日数を取得する
|
||||
@details
|
||||
年月日に変換するために使用する経過日数です。
|
||||
GetDays()との違いはマイナス(2000/1/1 0:0:0より前)の扱いで、例えば経過
|
||||
秒数が-1の場合、GetDays()は0を返しますが、GetDateDays()では-1を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetDateDays() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在の日時を経過秒数で取得する
|
||||
@return 経過秒数
|
||||
-----------------------------------------------------------------------*/
|
||||
static DateTimeSeconds GetCurrentDateTime();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在の日時で設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetCurrentDateTime();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
経過秒数 ←→ 年月日時分秒
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 年月日時分秒で取得する
|
||||
@param[out] pYear 年 ヌル可
|
||||
@param[out] pMonth 月 ヌル可
|
||||
@param[out] pDay 日 ヌル可
|
||||
@param[out] pHour 時 ヌル可
|
||||
@param[out] pMin 分 ヌル可
|
||||
@param[out] pSec 秒 ヌル可
|
||||
-----------------------------------------------------------------------*/
|
||||
void ConvertToParam(
|
||||
int* pYear, int* pMonth, int* pDay,
|
||||
int* pHour, int* pMin, int* pSec) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 年月日時分秒で設定する
|
||||
@param[in] nYear 年
|
||||
@param[in] nMonth 月
|
||||
@param[in] nDay 日
|
||||
@param[in] nHour 時
|
||||
@param[in] nMin 分
|
||||
@param[in] nSec 秒
|
||||
@return 変換に成功した場合はtrue
|
||||
@details
|
||||
無効な日付を指定した場合はfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ConvertFromParam(
|
||||
int nYear, int nMonth, int nDay,
|
||||
int nHour, int nMin, int nSec);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
経過秒数 ←→ nn::fnd::DateTime型
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief nn::fnd::DateTime型で取得する
|
||||
@return nn::fnd::DateTime型のデータ
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::fnd::DateTime ConvertToNNDateTime() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief nn::fnd::DateTime型で設定する
|
||||
@param[in] 日時
|
||||
-----------------------------------------------------------------------*/
|
||||
void ConvertFromNNDateTime(const nn::fnd::DateTime& rNNDT);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
経過秒数 ←→ 文字列
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 日時文字列で取得する
|
||||
@param[out] pStr 生成した文字列
|
||||
@param[in] nSize バッファのサイズ(文字数単位)
|
||||
@details
|
||||
文字列の形式は"YYYY:MM:DD HH:MM:SS"です。
|
||||
pStrはc_nStrinLength+1以上のバッファが必要です。
|
||||
-----------------------------------------------------------------------*/
|
||||
void ConvertToDateTimeString(char* pStr, int nSize) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 日時文字列で設定する
|
||||
@param[in] 日時
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ConvertFromDateTimeString(const char* pStr);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 有効な日時文字列かチェックする
|
||||
@param[in] pString 文字列
|
||||
@return 有効な場合はtrue
|
||||
@detail
|
||||
文字列の形式は"YYYY:MM:DD HH:MM:DD"です。
|
||||
-----------------------------------------------------------------------*/
|
||||
static bool IsValidDateTimeString(const char* pStr);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種比較演算子
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool operator==(const DateTimeSeconds& x) const{ return (GetSeconds() == x.GetSeconds()); }
|
||||
bool operator!=(const DateTimeSeconds& x) const{ return (GetSeconds() != x.GetSeconds()); }
|
||||
bool operator< (const DateTimeSeconds& x) const{ return (GetSeconds() < x.GetSeconds()); }
|
||||
bool operator<=(const DateTimeSeconds& x) const{ return (GetSeconds() <= x.GetSeconds()); }
|
||||
bool operator> (const DateTimeSeconds& x) const{ return (GetSeconds() > x.GetSeconds()); }
|
||||
bool operator>=(const DateTimeSeconds& x) const{ return (GetSeconds() >= x.GetSeconds()); }
|
||||
//@}
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_DATE_TIME_SECONDS_H_
|
||||
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbDebug.h
|
||||
|
||||
デバッグ関連機能
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_DEBUG_H_
|
||||
#define IMAGE_DB_DEBUG_H_
|
||||
|
||||
#include <nn/dbg.h>
|
||||
|
||||
|
||||
// NAND領域をSD上に再現する定義
|
||||
// 定義を有効にするとSD上にNANDがエミュレートされます。
|
||||
#if defined(IMAGE_DB_LIB)
|
||||
// #define IMG_DB_EMULATE_CTR_NAND_ON_SD
|
||||
// #define IMG_DB_EMULATE_TWL_NAND_ON_SD
|
||||
#else
|
||||
// #define IMG_DB_EMULATE_CTR_NAND_ON_SD
|
||||
// #define IMG_DB_EMULATE_TWL_NAND_ON_SD
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// 通常ログ表示の有効定義
|
||||
// ログを表示しない場合はコメントアウト
|
||||
//#define IMGDB_ENABLE_LOG
|
||||
|
||||
// 警告ログ表示の有効定義
|
||||
// ログを表示しない場合はコメントアウト
|
||||
//#define IMGDB_ENABLE_WARNING_LOG
|
||||
|
||||
// エラーログ表示の有効定義
|
||||
// ログを表示しない場合はコメントアウト
|
||||
//#define IMGDB_ENABLE_ERROR_LOG
|
||||
|
||||
|
||||
|
||||
#if defined(IMGDB_ENABLE_LOG)
|
||||
#define IMGDB_LOG(...) (NN_LOG("[ImageDb]"), NN_LOG(__VA_ARGS__))
|
||||
#else
|
||||
#define IMGDB_LOG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if defined(IMGDB_ENABLE_WARNING_LOG)
|
||||
#define IMGDB_WARNING(...) (NN_LOG("[ImageDb] Warning! "), NN_LOG(__VA_ARGS__))
|
||||
#else
|
||||
#define IMGDB_WARNING(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if defined(IMGDB_ENABLE_ERROR_LOG)
|
||||
#define IMGDB_ERROR(...) (NN_LOG("[ImageDb] Error!!! "), NN_LOG(__VA_ARGS__))
|
||||
#else
|
||||
#define IMGDB_ERROR(...) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // IMAGE_DB_DEBUG_H_
|
||||
@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbDirectory.h
|
||||
|
||||
ディレクトリ関連
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_DIRECTORY_H_
|
||||
#define IMAGE_DB_DIRECTORY_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/fs.h>
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbDynamicArray.h"
|
||||
#include "ImageDbTypes.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ディレクトリ操作クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class Directory
|
||||
{
|
||||
public:
|
||||
//! 拡張子リスト
|
||||
typedef DynamicArray< wchar_t*, XAllocator<wchar_t*> > ExtList;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator 使用するアロケータ
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath 操作するディレクトリのパス
|
||||
@param[in] nReadLimitNum 読み込み制限数(1~)
|
||||
@details
|
||||
pPathの末尾にスラッシュはつけないでください(例:"sdmc:/DCIM")。
|
||||
nReadLimitNumはRead()で順番にエントリーを読み込める回数です。ストレー
|
||||
ジが壊れている場合、Read()が終わらない事があるため、必ず制限を設けるよ
|
||||
うになっています。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じス
|
||||
トレージを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
Directory();
|
||||
Directory(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoType, const wchar_t* pPath,
|
||||
int nReadLimitNum);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~Directory();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化済みかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const{ return (0 != m_pAllocator); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@details
|
||||
既に初期化済みの場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoType, const wchar_t* pPath,
|
||||
int nReadLimitNum);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 解放する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Release();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリが操作できる状態か調べる
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsReady() const { return m_bReady; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 次のエントリを読み込む
|
||||
@return 終端でエントリが存在しない場合はfalse
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Read();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在のエントリを取得する
|
||||
@return エントリ
|
||||
@details
|
||||
終端でエントリが存在しない場合はヌルを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
const nn::fs::DirectoryEntry* GetEntry() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在のエントリがディレクトリか調べる
|
||||
@return ディレクトリならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsDirectory() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在のエントリがファイルか調べる
|
||||
@param[in] pExt 拡張子
|
||||
@param[in] rExtList 拡張子リスト
|
||||
@return ファイルならtrue
|
||||
@details
|
||||
拡張子を指定した場合は、ファイルで且つその拡張子の場合trueを返します。
|
||||
拡張子リストを指定した場合は、ファイル且つリストのいずれかの拡張子の場合
|
||||
trueを返します。
|
||||
拡張子にドットは不要で大文字で指定してください(例:"JPG")。
|
||||
ファイルシステムの特性として、ファイル名はすべて大文字で統一されています
|
||||
が、ディレクトリ名は大文字、小文字が区別されています。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool IsFile() const;
|
||||
bool IsFile(const wchar_t* pExt) const;
|
||||
bool IsFile(const ExtList& rExtList) const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
static const int c_nCacheSize = 64;
|
||||
|
||||
private:
|
||||
Allocator* m_pAllocator;
|
||||
bool m_bReady;
|
||||
NN_PADDING3;
|
||||
|
||||
StorageType m_eStoType;
|
||||
NN_PADDING3;
|
||||
nn::fs::Directory m_Directory;
|
||||
nn::fs::DirectoryEntry* m_pEntries;
|
||||
int m_nEntryNum;
|
||||
int m_nEntryIndex;
|
||||
int m_nReadLimitNum;
|
||||
int m_nReadCnt;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_DIRECTORY_H_
|
||||
@ -0,0 +1,753 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbDynamicArray.h
|
||||
|
||||
動的配列
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IMAGE_DB_DYNAMIC_ARRAY_H_
|
||||
#define IMAGE_DB_DYNAMIC_ARRAY_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <iterator>
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 動的配列
|
||||
@details
|
||||
STL準拠のシーケンシャルなランダムアクセス可能コンテナです。
|
||||
std::vectorと同じような仕様になっていますが、メモリ管理が異なります。
|
||||
std::vectorではキャパシティは2倍ずつ(?)増えますが、DyamicArrayはメモリブ
|
||||
ロックという単位で増えていきます。またstd::vectorではキャパシティは減ること
|
||||
はありませんが、DyamicArrayはメモリブロック単位で減少します。
|
||||
このような違いからstd::vectorに比べ、メモリの無駄は少ないですが、メモリの再
|
||||
確保の頻度は多くなります。
|
||||
メモリ確保の頻度下げるには、コンストラクタに渡すmemconと、reserve()で調整す
|
||||
る必要が有ります。
|
||||
memconは前述のメモリブロックのサイズです。このサイズを大きくすることで無駄な
|
||||
メモリは増えますが、その分再確保の頻度は下がります。
|
||||
reserve()はキャパシティの最低サイズになります。reserve()を設定しておけば、こ
|
||||
の値の範囲内であれば、要素の追加削除を行っても再確保は発生しません。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
#pragma pack(push, 4)
|
||||
template< typename T, typename Allocator=std::allocator<T> >
|
||||
class DynamicArray
|
||||
{
|
||||
public:
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef typename Allocator::reference reference;
|
||||
typedef typename Allocator::const_reference const_reference;
|
||||
typedef typename Allocator::value_type value_type;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
typedef typename Allocator::difference_type difference_type;
|
||||
typedef typename Allocator::pointer pointer;
|
||||
typedef typename Allocator::const_pointer const_pointer;
|
||||
typedef Allocator allocator_type;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief メモリ管理クラス
|
||||
-----------------------------------------------------------------------*/
|
||||
class MemoryControl {
|
||||
public:
|
||||
//! デフォルトのブロックサイズ
|
||||
static const size_type c_nDefaultBlockSize = 32;
|
||||
|
||||
/*!------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] block_size ブロックサイズ
|
||||
-------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit MemoryControl(size_type block_size=c_nDefaultBlockSize) : m_nBlockSize(block_size){}
|
||||
MemoryControl(const MemoryControl& x) : m_nBlockSize(x.GetBlockSize()){}
|
||||
//@}
|
||||
|
||||
/*!------------------------------------------------------------------
|
||||
@brief ブロックサイズを取得する
|
||||
@param[in] block_size ブロックサイズ
|
||||
-------------------------------------------------------------------*/
|
||||
size_type GetBlockSize() const{ return m_nBlockSize; }
|
||||
|
||||
private:
|
||||
const size_type m_nBlockSize;
|
||||
};
|
||||
|
||||
private:
|
||||
template<int v> struct Int2Type{ enum{value=v}; };
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] memcon メモリ管理
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit DynamicArray(const allocator_type& a=allocator_type());
|
||||
explicit DynamicArray(size_type n, const_reference value=T(), const allocator_type& a=allocator_type());
|
||||
template< typename InpIt >
|
||||
DynamicArray(InpIt first, InpIt last, const allocator_type& a=allocator_type());
|
||||
DynamicArray(const DynamicArray< T,allocator_type >& x);
|
||||
|
||||
explicit DynamicArray(MemoryControl memcon, const allocator_type& a=allocator_type());
|
||||
DynamicArray(MemoryControl memcon, size_type n, const_reference value=T(), const allocator_type& a=allocator_type());
|
||||
template< typename InpIt >
|
||||
DynamicArray(MemoryControl memcon, InpIt first, InpIt last, const allocator_type& a=allocator_type());
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~DynamicArray(){ Destroy(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief イテレータを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
iterator begin(){ return iterator(m_pBegin); }
|
||||
const_iterator begin() const{ return const_iterator(m_pBegin); }
|
||||
iterator end(){ return iterator(m_pEnd); }
|
||||
const_iterator end() const{ return const_iterator(m_pEnd); }
|
||||
|
||||
reverse_iterator rbegin(){ return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
|
||||
reverse_iterator rend(){ return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const{ return const_reverse_iterator(begin()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定要素を削除する
|
||||
@return 戻り値は削除された最終要素の直後のイテレータ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
iterator erase(iterator position){ return erase(position, position+1); }
|
||||
iterator erase(iterator first, iterator last);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素をすべて削除する
|
||||
-----------------------------------------------------------------------*/
|
||||
void clear(){ resize(0); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素を追加する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
iterator insert(iterator position, const_reference x);
|
||||
void insert(iterator position, size_type n, const_reference x){ Insert(position, n, x, Int2Type<true>()); }
|
||||
template< typename InpIt >
|
||||
void insert(iterator position, InpIt first, InpIt last){
|
||||
Insert(position, first, last, Int2Type<std::numeric_limits<InpIt>::is_integer>()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 末尾へのプッシュ/ポップ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void pop_back(){ erase(end()-1); }
|
||||
void push_back(const_reference x){ insert(end(), x); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 先頭へのプッシュ/ポップ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void pop_front(){ erase(begin()); }
|
||||
void push_front(const_reference x){ insert(begin(), x); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在の要素を破棄して、新しく要素割り当てる
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
template< typename InpIt >
|
||||
void assign(InpIt first, InpIt last){
|
||||
Assign(first, last, Int2Type<std::numeric_limits<InpIt>::is_integer>()); }
|
||||
void assign(size_type n, const_reference c){ m_pEnd = m_pBegin; resize(n, c); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素数を変更する
|
||||
-----------------------------------------------------------------------*/
|
||||
void resize(size_type n, T c=T());
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素を交換する
|
||||
-----------------------------------------------------------------------*/
|
||||
void swap(DynamicArray<T,Allocator>& that);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 末尾の要素を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
reference back(){ return *(end()-1); }
|
||||
const_reference back() const{ return *(end()-1); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 先頭の要素を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
reference front(){ return *begin(); }
|
||||
const_reference front() const{ return *begin(); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
size_type size() const{ return m_pEnd - m_pBegin; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素が空(ゼロ)かチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool empty() const{ return (0 == size()); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 割り当て可能な最大要素数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
size_type max_size() const{ return std::numeric_limits<size_type>::max(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 要素を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
reference at(size_type n){ return m_pBegin[n]; }
|
||||
const_reference at(size_type n) const{ return m_pBegin[n]; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief メモリ再確保なしに確保できる要素数
|
||||
-----------------------------------------------------------------------*/
|
||||
size_type capacity() const{ return m_nCapacity; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最低キャパシティサイズを設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
void reserve(size_type n);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アロケータを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
allocator_type get_allocator() const{ return m_Allocator; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief メモリ管理を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
const MemoryControl& get_memcon() const{ return m_MemCon; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種オペレータ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
DynamicArray& operator=(const DynamicArray& v){ assign(v.begin(), v.end()); return *this; }
|
||||
|
||||
reference operator[](size_type n){ return at(n); }
|
||||
const_reference operator[](size_type n) const{ return at(n); }
|
||||
//@}
|
||||
|
||||
private:
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArrayInternal(T1 n, T2 value, Int2Type<true>);
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArrayInternal(T1 first, T2 last, Int2Type<false>);
|
||||
|
||||
template< typename T1, typename T2 >
|
||||
void Insert(iterator position, T1 n, T2 value, Int2Type<true>);
|
||||
template< typename T1, typename T2 >
|
||||
void Insert(iterator position, T1 first, T2 last, Int2Type<false>);
|
||||
|
||||
template< typename T1, typename T2 >
|
||||
void Assign(T1 n, T2 value, Int2Type<true>);
|
||||
template< typename T1, typename T2 >
|
||||
void Assign(T1 first, T2 last, Int2Type<false>);
|
||||
|
||||
bool IsSetReserveSize() const{ return (m_MemCon.GetBlockSize() < m_nReserveSize); }
|
||||
void SetAddress(value_type* p, size_type n);
|
||||
void Create(size_type n);
|
||||
void Create(size_type n, size_type capa);
|
||||
void Recreate(size_type n);
|
||||
void Destroy();
|
||||
void Refresh();
|
||||
|
||||
private:
|
||||
// m_pBegin m_pEnd
|
||||
// 下位├─────┼────┼───┤上位
|
||||
// ← size() →
|
||||
// ←─ m_nReserveSize →
|
||||
// ←──── m_nCapacity ───→
|
||||
|
||||
allocator_type m_Allocator;
|
||||
NN_PADDING3;
|
||||
MemoryControl m_MemCon;
|
||||
|
||||
size_type m_nCapacity;
|
||||
size_type m_nReserveSize;
|
||||
T* m_pBegin;
|
||||
T* m_pEnd;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
コンストラクタ
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
DynamicArray<T, Allocator>::DynamicArray(const allocator_type& a)
|
||||
: m_Allocator(a)
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
SetAddress(0, 0);
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
DynamicArray<T, Allocator>::DynamicArray(size_type n, const_reference value, const allocator_type& a)
|
||||
: m_Allocator(a)
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
DynamicArrayInternal(n, value, Int2Type<true>());
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
template< typename InpIt >
|
||||
DynamicArray<T, Allocator>::DynamicArray(InpIt first, InpIt last, const allocator_type& a)
|
||||
: m_Allocator(a)
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
DynamicArrayInternal(first, last, Int2Type<std::numeric_limits<InpIt>::is_integer>());
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
DynamicArray<T, Allocator>::DynamicArray(const DynamicArray< T,allocator_type >& x)
|
||||
: m_Allocator(x.get_allocator())
|
||||
, m_MemCon(x.get_memcon())
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
DynamicArrayInternal(x.begin(), x.end(), Int2Type<false>());
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
DynamicArray<T, Allocator>::DynamicArray(MemoryControl memcon, const allocator_type& a)
|
||||
: m_Allocator(a)
|
||||
, m_MemCon(memcon)
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
SetAddress(0, 0);
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
DynamicArray<T, Allocator>::DynamicArray(MemoryControl memcon, size_type n, const_reference value, const allocator_type& a)
|
||||
: m_Allocator(a)
|
||||
, m_MemCon(memcon)
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
DynamicArrayInternal(n, value, Int2Type<true>());
|
||||
}
|
||||
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
template< typename InpIt >
|
||||
DynamicArray<T, Allocator>::DynamicArray(MemoryControl memcon, InpIt first, InpIt last, const allocator_type& a)
|
||||
: m_Allocator(a)
|
||||
, m_MemCon(memcon)
|
||||
, m_nCapacity(0)
|
||||
, m_nReserveSize(0)
|
||||
, m_pBegin(0)
|
||||
, m_pEnd(0)
|
||||
{
|
||||
DynamicArrayInternal(first, last, Int2Type<std::numeric_limits<InpIt>::is_integer>());
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
指定要素を削除する
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
typename DynamicArray<T, Allocator>::iterator DynamicArray<T, Allocator>::erase(iterator first, iterator last)
|
||||
{
|
||||
size_type nPos = first - begin();
|
||||
|
||||
// last以降のデータをfirst側に詰めていく
|
||||
{
|
||||
iterator s = first;
|
||||
const_iterator e = last;
|
||||
while(e != end()){
|
||||
*(s++) = *(e++);
|
||||
}
|
||||
}
|
||||
|
||||
// 削除により詰めたendに設定する
|
||||
const size_type nEraseNum = last - first;
|
||||
SetAddress(begin(), size()-nEraseNum);
|
||||
|
||||
Refresh();
|
||||
|
||||
return begin() + nPos;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
指定要素追加
|
||||
positionの手前に追加される
|
||||
戻り値は追加された要素のイテレータ
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
typename DynamicArray<T, Allocator>::iterator DynamicArray<T, Allocator>::insert(iterator position, const_reference x)
|
||||
{
|
||||
const size_type pos = position - m_pBegin;
|
||||
|
||||
// キャパシティに余裕が無ければリサイズして要素数を増やす
|
||||
if(size() + 1 > capacity()){
|
||||
Recreate(size() + 1);
|
||||
}
|
||||
|
||||
// 挿入する位置より後ろのデータをずらす
|
||||
const size_type nMoveNum = size() - pos;
|
||||
for(size_type i = 0; i < nMoveNum; ++i){
|
||||
m_pBegin[size()-i] = m_pBegin[size()-1-i];
|
||||
}
|
||||
|
||||
// データを挿入する
|
||||
++m_pEnd;
|
||||
m_pBegin[pos] = x;
|
||||
|
||||
return m_pBegin + pos;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
要素数を変更する
|
||||
増えた場合はcで埋められる
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::resize(size_type n, T c)
|
||||
{
|
||||
// 増える
|
||||
if(size() < n){
|
||||
// キャパシティが不足している場合はメモリを確保しなおす
|
||||
if(capacity() < n){
|
||||
Recreate(n);
|
||||
}
|
||||
|
||||
// 追加された要素に指定データを格納する
|
||||
while(size() < n){
|
||||
push_back(c);
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
// 減る
|
||||
else if(size() > n){
|
||||
m_pEnd -= size() - n;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
すべての要素を入れ替える
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::swap(DynamicArray<T,Allocator>& that)
|
||||
{
|
||||
const size_type nThisSize = size();
|
||||
const size_type nThatSize = that.size();
|
||||
const size_type nMaxSize = std::max(nThisSize, nThatSize);
|
||||
|
||||
// どちらも同じサイズにする
|
||||
if(nMaxSize > size()){
|
||||
resize(nMaxSize);
|
||||
}
|
||||
else if(nMaxSize > that.size()){
|
||||
that.resize(nMaxSize);
|
||||
}
|
||||
|
||||
// 交換する
|
||||
for(size_type i = 0; i < nMaxSize; ++i){
|
||||
std::swap(at(i), that.at(i));
|
||||
}
|
||||
|
||||
// 交換後のサイズに設定する
|
||||
resize(nThatSize);
|
||||
that.resize(nThisSize);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
キャパシティをn以上に保つ
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::reserve(size_type n)
|
||||
{
|
||||
m_nReserveSize = n;
|
||||
if(m_nCapacity < m_nReserveSize){
|
||||
Recreate(n);
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
コンストラクタ内部実装
|
||||
DynamicArray(size_type n, const_reference value)と
|
||||
template<typename InpIt> DynamicArray(InpIt first, InpIt last)の内部実装。
|
||||
コンストラクタに整数を渡した場合、前者のコンストラクタの呼出を期待してても
|
||||
後者がよばれ、意図しない挙動になります。
|
||||
そのため引数の型をチェックして、明確に呼出を振り分けるために別関数に分けて
|
||||
います。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArray<T, Allocator>::DynamicArrayInternal(T1 n, T2 value, Int2Type<true>){
|
||||
Create(n);
|
||||
for(size_type i = 0; i < size(); ++i){
|
||||
m_Allocator.construct(&m_pBegin[i], value);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArray<T, Allocator>::DynamicArrayInternal(T1 first, T2 last, Int2Type<false>){
|
||||
Create(last - first);
|
||||
for(size_type i = 0; i < size(); ++i){
|
||||
m_Allocator.construct(&m_pBegin[i], *first++);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
insert内部実装
|
||||
void insert(iterator position, size_type n, const_reference x)と
|
||||
template<typename InpIt> void insert(iterator position, InpIt first, InpIt last)の内部実装。
|
||||
引数に整数を渡した場合、前者のinsertの呼出を期待してても後者がよばれ、意
|
||||
図しない挙動になります。
|
||||
そのため引数の型をチェックして、明確に呼出を振り分けるために別関数に分けて
|
||||
います。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArray<T, Allocator>::Insert(iterator position, T1 n, T2 x, Int2Type<true>)
|
||||
{
|
||||
const size_type pos = position - m_pBegin;
|
||||
|
||||
// キャパシティに余裕が無ければリサイズして要素数を増やす
|
||||
if(size() + n > capacity()){
|
||||
Recreate(size() + 1);
|
||||
}
|
||||
|
||||
// 挿入する位置より後ろのデータをずらす
|
||||
const size_type nMoveNum = size() - pos;
|
||||
for(size_type i = 0; i < nMoveNum; ++i){
|
||||
m_pBegin[size()+(n-1)-i] = m_pBegin[size()-1-i];
|
||||
}
|
||||
|
||||
// データを挿入する
|
||||
m_pEnd += n;
|
||||
for(T1 i = 0; i < n; ++i){
|
||||
m_pBegin[pos+i] = x;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArray<T, Allocator>::Insert(iterator position, T1 first, T2 last, Int2Type<false>)
|
||||
{
|
||||
const size_type pos = position - m_pBegin;
|
||||
const size_type n = last - first;
|
||||
|
||||
// キャパシティに余裕が無ければリサイズして要素数を増やす
|
||||
if(size() + n > capacity()){
|
||||
Recreate(size() + 1);
|
||||
}
|
||||
|
||||
// 挿入する位置より後ろのデータをずらす
|
||||
const size_type nMoveNum = size() - pos;
|
||||
for(size_type i = 0; i < nMoveNum; ++i){
|
||||
m_pBegin[size()+(n-1)-i] = m_pBegin[size()-1-i];
|
||||
}
|
||||
|
||||
// データを挿入する
|
||||
m_pEnd += n;
|
||||
for(size_type i = 0; i < n; ++i){
|
||||
m_pBegin[pos+i] = first[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
assign内部実装
|
||||
void assign(size_type n, const_reference u)と
|
||||
template<typename InpIt> void assign(InpIt first, InpIt last)の内部実装。
|
||||
引数に整数を渡した場合、前者のassignの呼出を期待してても後者がよばれ、意
|
||||
図しない挙動になります。
|
||||
そのため引数の型をチェックして、明確に呼出を振り分けるために別関数に分けて
|
||||
います。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArray<T, Allocator>::Assign(T1 n, T2 value, Int2Type<true>)
|
||||
{
|
||||
m_pEnd = m_pBegin;
|
||||
resize(n, value);
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
template< typename T1, typename T2 >
|
||||
void DynamicArray<T, Allocator>::Assign(T1 first, T2 last, Int2Type<false>)
|
||||
{
|
||||
m_pEnd = m_pBegin;
|
||||
insert(begin(), first, last);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
BeginとEndのアドレス設定
|
||||
p Beginのポインタ
|
||||
n 要素数
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::SetAddress(value_type* p, size_type n)
|
||||
{
|
||||
m_pBegin = p;
|
||||
m_pEnd = p + n;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
メモリを確保する
|
||||
n 要素数
|
||||
capa 確保するサイズ
|
||||
|
||||
以前のメモリを解放し、新規にcapaの要素数分のメモリを確保します。
|
||||
capaを省略した場合は、リザーブやブロックサイズから適当に求めます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::Create(size_type n)
|
||||
{
|
||||
size_type nNewCapa = n + m_MemCon.GetBlockSize();
|
||||
|
||||
// 求めたキャパシティがリザーブより下回っている場合は調整する
|
||||
if(IsSetReserveSize() && nNewCapa < m_nReserveSize){
|
||||
nNewCapa = m_nReserveSize;
|
||||
}
|
||||
|
||||
if(capacity() != nNewCapa){
|
||||
Create(n, nNewCapa);
|
||||
}
|
||||
else{
|
||||
// 再確保の必要が無いのでend()だけ調整する
|
||||
SetAddress(m_pBegin, n);
|
||||
}
|
||||
}
|
||||
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::Create(size_type n, size_type capa)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
if(0 < capa){
|
||||
m_nCapacity = capa;
|
||||
SetAddress(m_Allocator.allocate(m_nCapacity, 0), n);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
メモリを再確保する
|
||||
n 確保する要素数
|
||||
|
||||
以前の要素を維持したまま、n+ブロックサイズのキャパシティを再確保します。
|
||||
以前よりも少なくなる場合は、nまでの要素が維持されます。
|
||||
例えば要素数10の「abcdefghij」を、Recreate(3)とすると「abc???」となります。
|
||||
「?」はブロックサイズ分のメモリで不定値となります。
|
||||
また減ったことによりend()も「cの次」に調整されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::Recreate(size_type n)
|
||||
{
|
||||
size_type nNewCapa = n + m_MemCon.GetBlockSize();
|
||||
|
||||
// 求めたキャパシティがリザーブより下回っている場合は調整する
|
||||
if(IsSetReserveSize() && nNewCapa < m_nReserveSize){
|
||||
nNewCapa = m_nReserveSize;
|
||||
}
|
||||
|
||||
if(capacity() != nNewCapa){
|
||||
value_type* pNewBegin = 0;
|
||||
size_type nNewSize = 0;
|
||||
|
||||
if(0 < nNewCapa){
|
||||
pNewBegin = m_Allocator.allocate(nNewCapa, 0);
|
||||
nNewSize = (size() <= n) ? size() : n;
|
||||
|
||||
for(size_type i = 0; i < nNewSize; ++i){
|
||||
pNewBegin[i] = m_pBegin[i];
|
||||
}
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
m_nCapacity = nNewCapa;
|
||||
SetAddress(pNewBegin, nNewSize);
|
||||
}
|
||||
else{
|
||||
// 再確保の必要が無いのでend()だけ調整する
|
||||
SetAddress(m_pBegin, n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
保持しているメモリを解放する
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::Destroy()
|
||||
{
|
||||
if(0 != m_pBegin){
|
||||
// 要素のデストラクタを呼び出してからメモリを解放する
|
||||
for(size_type i = 0; i < size(); ++i){
|
||||
m_Allocator.destroy(&m_pBegin[i]);
|
||||
}
|
||||
m_Allocator.deallocate(m_pBegin, capacity());
|
||||
m_pBegin = m_pEnd = 0;
|
||||
m_nCapacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
キャパシティの無駄な空きを減らす
|
||||
*---------------------------------------------------------------------------*/
|
||||
template< typename T, typename Allocator >
|
||||
void DynamicArray<T, Allocator>::Refresh()
|
||||
{
|
||||
// 空きキャパシティが一定以上であればリサイズしてメモリを詰める
|
||||
if(m_MemCon.GetBlockSize()*2 <= capacity() - size()){
|
||||
if(empty() && !IsSetReserveSize()){
|
||||
Destroy();
|
||||
}
|
||||
else{
|
||||
Recreate(size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_DYNAMIC_ARRAY_H_
|
||||
@ -0,0 +1,235 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbFaceInfo.h
|
||||
|
||||
顔情報
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_FACE_INFO_H_
|
||||
#define IMAGE_DB_FACE_INFO_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 顔情報データ構造体(POD)
|
||||
@note
|
||||
座標は[0.0, 1.0)のUV値で、整数部0bit:小数部16bitの符号なし固定小数で格納さ
|
||||
れています。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct FaceInfo
|
||||
{
|
||||
//! 空データの信頼度
|
||||
static const int c_nConfEmpty = 0;
|
||||
//! 信頼度の最小値
|
||||
static const int c_nConfMin = 1;
|
||||
//! 信頼度の最大値
|
||||
static const int c_nConfMax = 1000;
|
||||
//! 固定小数の小数部のビット数
|
||||
static const int c_nFixedPointBit = 16;
|
||||
|
||||
|
||||
//! フィールド
|
||||
u16 nField; // 0~ 9bit 信頼度 低[0,1000]高 0はデータなし
|
||||
// 10~15bit 予約
|
||||
|
||||
//! 顔の境界ボックス(固定小数)
|
||||
//@{
|
||||
u16 nBoundingBoxLeft;
|
||||
u16 nBoundingBoxTop;
|
||||
u16 nBoundingBoxRight;
|
||||
u16 nBoundingBoxBottom;
|
||||
//@}
|
||||
|
||||
//! 左目の座標(固定小数)
|
||||
//@{
|
||||
u16 nLeftEyeX;
|
||||
u16 nLeftEyeY;
|
||||
//@}
|
||||
|
||||
//! 右目の座標(固定小数)
|
||||
//@{
|
||||
u16 nRightEyeX;
|
||||
u16 nRightEyeY;
|
||||
//@}
|
||||
|
||||
//----- フィールド -----//
|
||||
// bit0-9 信頼度
|
||||
static const int c_nFieldConfBits = 10;
|
||||
static const int c_nFieldConfShift = 0;
|
||||
static const u32 c_nFieldConfMask = ((1<<c_nFieldConfBits)-1)<<c_nFieldConfShift;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 空の顔情報かチェックする
|
||||
@return 空ならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsEmpty() const{ return (c_nConfEmpty == GetConfidence()); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔の信頼度を取得/設定する
|
||||
@param[in] 信頼度
|
||||
@details
|
||||
c_nConfMin~c_nConfMaxの値を指定してください。
|
||||
範囲外のデータを指定した場合は、空データ(c_nConfEmpty)として設定されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetConfidence() const;
|
||||
void SetConfidence(int nConf);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔の境界ボックスをピクセル単位で取得する
|
||||
@param[in] nWidth 基準となる幅(ピクセル単位)
|
||||
@param[in] nHeight 基準となる高さ(ピクセル単位)
|
||||
@param[out] pLeft 矩形左(ヌル可、ピクセル単位)
|
||||
@param[out] pTop 矩形上(ヌル可、ピクセル単位)
|
||||
@param[out] pRight 矩形右(ヌル可、ピクセル単位)
|
||||
@param[out] pBottom 矩形下(ヌル可、ピクセル単位)
|
||||
@details
|
||||
nWidthとnHeightにピクセル単位での画像サイズを渡すと、顔の境界ボックスの
|
||||
矩形座標をピクセル単位で返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetBoundingBoxByPixel(
|
||||
int nWidth, int nHeight,
|
||||
int* pLeft, int* pTop, int* pRight, int* pBottom) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔の境界ボックスをピクセル単位で設定する
|
||||
@param[in] nWidth 基準となる幅(ピクセル単位)
|
||||
@param[in] nHeight 基準となる高さ(ピクセル単位)
|
||||
@param[in] nLeft 矩形左(ピクセル単位)
|
||||
@param[in] nTop 矩形上(ピクセル単位)
|
||||
@param[in] nRight 矩形右(ピクセル単位)
|
||||
@param[in] nBottom 矩形下(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetBoundingBoxByPixel(
|
||||
int nWidth, int nHeight,
|
||||
int nLeft, int nTop, int nRight, int nBottom);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔の境界ボックスを浮動小数UV値で取得する
|
||||
@param[out] pLeft 矩形左(ヌル可)
|
||||
@param[out] pTop 矩形上(ヌル可)
|
||||
@param[out] pRight 矩形右(ヌル可)
|
||||
@param[out] pBottom 矩形下(ヌル可)
|
||||
@details
|
||||
[0.0, 1.0)のUV値を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetBoundingBoxByFloatUV(
|
||||
f32* pLeft, f32* pTop, f32* pRight, f32* pBottom) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔の境界ボックスを浮動小数UV値で設定する
|
||||
@param[in] fLeft 矩形左(UV値)
|
||||
@param[in] fTop 矩形上(UV値)
|
||||
@param[in] fRight 矩形右(UV値)
|
||||
@param[in] fBottom 矩形下(UV値)
|
||||
@details
|
||||
[0.0, 1.0)のUV値を返します。
|
||||
範囲外の値を指定した場合は範囲内にクリップされて格納されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetBoundingBoxByFloatUV(
|
||||
f32 fLeft, f32 fTop, f32 fRight, f32 fBottom);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 左目の座標をピクセル単位で取得する
|
||||
@param[in] nWidth 基準となる幅(ピクセル単位)
|
||||
@param[in] nHeight 基準となる高さ(ピクセル単位)
|
||||
@param[out] pX X座標(ヌル可、ピクセル単位)
|
||||
@param[out] pY Y座標(ヌル可、ピクセル単位)
|
||||
@details
|
||||
nWidthとnHeightにピクセル単位での画像サイズを渡すと、左目の座標をピクセ
|
||||
ル単位で返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetLeftEyeByPixel(int nWidth, int nHeight, int* pX, int* pY) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 左目の座標をピクセル単位で設定する
|
||||
@param[in] nWidth 基準となる幅
|
||||
@param[in] nHeight 基準となる高さ
|
||||
@param[in] nX X座標(ピクセル単位)
|
||||
@param[in] nY Y座標(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetLeftEyeByPixel(int nWidth, int nHeight, int nX, int nY);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 左目の座標を浮動小数UV値で取得する
|
||||
@param[out] pX X座標(ヌル可、UV単位)
|
||||
@param[out] pY Y座標(ヌル可、UV単位)
|
||||
@details
|
||||
[0.0, 1.0)のUV値を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetLeftEyeByFloatUV(int* pX, int* pY) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 左目の座標を浮動小数UV値で設定する
|
||||
@param[in] fX X座標(UV値)
|
||||
@param[in] fY Y座標(UV値)
|
||||
@details
|
||||
[0.0, 1.0)のUV値を返します。
|
||||
範囲外の値を指定した場合は範囲内にクリップされて格納されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetLeftEyeByFloatUV(f32 fX, f32 fY);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 右目の座標をピクセル単位で取得する
|
||||
@param[in] nWidth 基準となる幅(ピクセル単位)
|
||||
@param[in] nHeight 基準となる高さ(ピクセル単位)
|
||||
@param[out] pX X座標(ヌル可、ピクセル単位)
|
||||
@param[out] pY Y座標(ヌル可、ピクセル単位)
|
||||
@details
|
||||
nWidthとnHeightにピクセル単位での画像サイズを渡すと、右目の座標をピクセ
|
||||
ル単位で返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetRightEyeByPixel(int nWidth, int nHeight, int* pX, int* pY) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 右目の座標をピクセル単位で設定する
|
||||
@param[in] nWidth 基準となる幅
|
||||
@param[in] nHeight 基準となる高さ
|
||||
@param[in] nX X座標(ピクセル単位)
|
||||
@param[in] nY Y座標(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetRightEyeByPixel(int nWidth, int nHeight, int nX, int nY);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 右目の座標を浮動小数UV値で取得する
|
||||
@param[out] pX X座標(ヌル可、UV単位)
|
||||
@param[out] pY Y座標(ヌル可、UV単位)
|
||||
@details
|
||||
[0.0, 1.0)のUV値を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetRightEyeByFloatUV(int* pX, int* pY) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 右目の座標を浮動小数UV値で設定する
|
||||
@param[in] fX X座標(UV値)
|
||||
@param[in] fY Y座標(UV値)
|
||||
@details
|
||||
[0.0, 1.0)のUV値を返します。
|
||||
範囲外の値を指定した場合は範囲内にクリップされて格納されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetRightEyeByFloatUV(f32 fX, f32 fY);
|
||||
|
||||
private:
|
||||
static u16 Float2Fix(f32 fFloat);
|
||||
static f32 Fix2Float(u16 nFix);
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_FACE_INFO_H_
|
||||
@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageFileDuplicator.h
|
||||
|
||||
映像ファイル複製
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_FILE_DUPLICATOR_H_
|
||||
#define IMAGE_DB_FILE_DUPLICATOR_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像ファイル複製クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageFileDuplicator : private nn::util::NonCopyable<ImageFileDuplicator>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] eStoTypeSrc 複製元のストレージ
|
||||
@param[in] rImgInfoSrc 複製元の映像情報
|
||||
@param[in] pSrcData 複製元のデータ
|
||||
@param[in] nSrcDataSize 複製元のデータサイズ
|
||||
@param[in] eStoTypeDst 複製先のストレージ
|
||||
@param[in] rImgInfoDst 複製先の映像情報
|
||||
@param[in] rCreateSeconds ファイル生成日時
|
||||
@details
|
||||
複製元のデータが既にメモリ上に存在する場合は、pSrcDataとnSrcDataSizeで
|
||||
そのデータを指定するとファイルから読み込むことなく複製できます。
|
||||
その際JPEGやMPなど適切なデータを指定してください。また複製の過程でファ
|
||||
イル作成日時を書き換えます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ImageFileDuplicator(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoTypeSrc, const ImageInfo& rImgInfoSrc,
|
||||
StorageType eStoTypeDst, const ImageInfo& rImgInfoDst,
|
||||
const DateTimeSeconds& rCreateSeconds);
|
||||
ImageFileDuplicator(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoTypeSrc, const ImageInfo& rImgInfoSrc,
|
||||
void* pSrcData, std::size_t nSrcDataSize,
|
||||
StorageType eStoTypeDst, const ImageInfo& rImgInfoDst,
|
||||
const DateTimeSeconds& rCreateSeconds);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~ImageFileDuplicator();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 複製する
|
||||
@param[out] rResultSrc 転送元の処理結果
|
||||
@param[out] rResultDst 転送先の処理結果
|
||||
@return すべて問題なければtrue
|
||||
戻り値がfalseの場合はrResultSrcとrResultDstのいずれか、または両方にエラー
|
||||
が格納されていることになります。
|
||||
基本的にrResultSrc側で失敗したら、その後の処理が行えないことが多く、そ
|
||||
の場合のrResultDstはResultErrorになります。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Duplicate(Result& rResultSrc, Result& rResultDst);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 複製元の読み込むストレージを取得する
|
||||
@return 複製元のストレージ
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageTypeSrc() const { return m_eStoTypeSrc; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 複製先の読み込むストレージを取得する
|
||||
@return 複製先のストレージ
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageTypeDst() const { return m_eStoTypeDst; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 複製元の映像情報を取得する
|
||||
@return 複製元の映像情報
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageInfo& GetImageInfoSrc() const { return m_rImgInfoSrc; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 複製先の映像情報を取得する
|
||||
@return 複製先の映像情報
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageInfo& GetImageInfoDst() const { return m_rImgInfoDst; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル生成日時を取得する
|
||||
@return ファイル生成日時
|
||||
-----------------------------------------------------------------------*/
|
||||
const DateTimeSeconds& GetCreateSecond() const { return m_sCreateSeconds; }
|
||||
|
||||
private:
|
||||
bool DuplicateJpeg(Result& rResultSrc, Result& rResultDst) const;
|
||||
bool DuplicateMp(Result& rResultSrc, Result& rResultDst) const;
|
||||
|
||||
//Result DuplicateFile(const XWString& rPathSrc, const XWString& rPathDst);
|
||||
|
||||
private:
|
||||
// 読み書きバッファサイズ
|
||||
// このサイズずつ読み書きする
|
||||
//static const int c_nIOBufferSize = 32*1024;
|
||||
|
||||
private:
|
||||
Allocator& m_rAllocator;
|
||||
|
||||
const StorageType m_eStoTypeSrc;
|
||||
const ImageInfo& m_rImgInfoSrc;
|
||||
void* m_pSrcData;
|
||||
const std::size_t m_nSrcDataSize;
|
||||
|
||||
const StorageType m_eStoTypeDst;
|
||||
const ImageInfo& m_rImgInfoDst;
|
||||
|
||||
const DateTimeSeconds m_sCreateSeconds;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_FILE_DUPLICATOR_H_
|
||||
@ -0,0 +1,498 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbFileReader.h
|
||||
|
||||
ファイル読み込み
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_FILE_READER_H_
|
||||
#define IMAGE_DB_FILE_READER_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbResult.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイル読み込みクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class FileReader : private nn::util::NonCopyable<FileReader>
|
||||
{
|
||||
public:
|
||||
// ファイルサイズ制限無し
|
||||
static const std::size_t c_nUnlimitFileSize = static_cast<std::size_t>(-1);
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] pBuf 読み込み先のバッファ
|
||||
@param[in] nLimitFileSize 読み込むファイルサイズの制限
|
||||
@param[in] nBufSize バッファのサイズ
|
||||
@param[in] bReadLimit 制限サイズ読み込みフラグ
|
||||
@details
|
||||
読み込むファイルのサイズがnLimitFileSizeより大きい場合は失敗となります。
|
||||
不特定のファイルを読み込む場合は制限を設けて使用してください。
|
||||
bReadLimitがtrueの場合、nLimitFileSize(またはnBufSize)サイズまで読み
|
||||
込んで成功とします。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit FileReader(Allocator& rAllocator);
|
||||
FileReader(
|
||||
Allocator& rAllocator,
|
||||
std::size_t nLimitFileSize, bool bReadLimit=false);
|
||||
FileReader(
|
||||
void* pBuf, std::size_t nBufSize, bool bReadLimit=false);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~FileReader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込む
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath ファイルパス
|
||||
@param[in] nStartPos ファイルの読み込み開始位置
|
||||
@param[in] nReadSize ファイル読み込みサイズ
|
||||
@return 成功した場合はtrue
|
||||
@details
|
||||
nReadSizeにゼロを指定した場合は、nStartPos以降すべてを読み込みます。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じスト
|
||||
レージを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
virtual bool Read(
|
||||
StorageType eStoType, const wchar_t* pPath);
|
||||
virtual bool Read(
|
||||
StorageType eStoType, const wchar_t* pPath,
|
||||
s64 nStartPos, std::size_t nReadSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだデータを取得する
|
||||
@return データ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetData() const;
|
||||
void* GetData();
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだデータサイズを取得する
|
||||
@return データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetDataSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだファイルサイズを取得する
|
||||
@return ファイルサイズ
|
||||
@details
|
||||
読み込み対象となったファイルのサイズです。
|
||||
実際に読み込んだサイズはGetDataSize()で取得できます。
|
||||
-----------------------------------------------------------------------*/
|
||||
s64 GetFileSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 結果を取得する
|
||||
@return 結果
|
||||
-----------------------------------------------------------------------*/
|
||||
Result GetResult() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief FSライブラリが返す結果を取得する
|
||||
@return 結果
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::Result GetNnResult() const;
|
||||
|
||||
protected:
|
||||
void* Alloc(std::size_t nSize);
|
||||
void Free(void* pAddr);
|
||||
|
||||
bool IsAvailableUserBuffer() const;
|
||||
|
||||
void AllocFileData(std::size_t nSize);
|
||||
void FreeFileData();
|
||||
|
||||
private:
|
||||
Allocator* m_pAllocator;
|
||||
void* m_pUserBuffer;
|
||||
const std::size_t m_nLimitFileOrBufSize;
|
||||
const bool m_bReadLimit;
|
||||
|
||||
void* m_pFileData;
|
||||
std::size_t m_nFileDataSize;
|
||||
s64 m_nFileSize;
|
||||
Result m_eResult;
|
||||
nn::Result m_NnResult;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真ファイル読み込みクラス
|
||||
@details
|
||||
使用前に一度だけSetLimitFileSize()を呼び出して制限サイズを指定してください。
|
||||
指定せずに使用するとアサートが発生しエラーを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PhotoFileReader : public FileReader
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] nLimFileSize 制限ファイルサイズ
|
||||
@details
|
||||
nLimFileSizeを省略した場合はSetDefaultLimitFileSize()で設定されている
|
||||
デフォルトサイズが使用されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit PhotoFileReader(Allocator& rAllocator);
|
||||
PhotoFileReader(Allocator& rAllocator, std::size_t nLimFileSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~PhotoFileReader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 制限ファイルサイズをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetLimitFileSize() const{ return m_nCurLimitFileSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デフォルトの制限ファイルサイズをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
static bool IsValidDefaultLimitFileSize();
|
||||
static std::size_t GetDefaultLimitFileSize();
|
||||
static void SetDefaultLimitFileSize(std::size_t nSize);
|
||||
//@}
|
||||
|
||||
private:
|
||||
static bool bSetDefaultLimitFileSize;
|
||||
static std::size_t nDefaultLimitFileSize;
|
||||
|
||||
private:
|
||||
std::size_t m_nCurLimitFileSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真ヘッダ部分ファイル読み込みクラス
|
||||
@details
|
||||
JPEGのExif(APP1)ぐらいまでを読み込みます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PhotoHeaderFileReader : public FileReader
|
||||
{
|
||||
public:
|
||||
// 読み込みファイルサイズ
|
||||
// SOIから本画像データがあるまでのマーカーが読み込めるぐらいのサイズです
|
||||
// 本来は決め打ちにできないサイズですが、これぐらいのサイズであれば大抵は
|
||||
// 対応できるサイズとなっています。
|
||||
static const std::size_t c_nReadFileSize = 128*1024;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] nLimFileSize 制限ファイルサイズ
|
||||
@details
|
||||
nLimFileSizeを省略した場合はSetDefaultLimitFileSize()で設定されている
|
||||
デフォルトサイズが使用されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit PhotoHeaderFileReader(Allocator& rAllocator);
|
||||
PhotoHeaderFileReader(Allocator& rAllocator, std::size_t nLimFileSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~PhotoHeaderFileReader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込む
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath ファイルパス
|
||||
@return 結果
|
||||
@details
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じスト
|
||||
レージを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
virtual bool Read(
|
||||
StorageType eStoType, const wchar_t* pPath);
|
||||
virtual bool Read(
|
||||
StorageType eStoType, const wchar_t* pPath,
|
||||
s64 nStartPos, std::size_t nReadSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 制限ファイルサイズをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetLimitFileSize() const{ return m_nCurLimitFileSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 制限ファイルサイズをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
static bool IsValidDefaultLimitFileSize();
|
||||
static std::size_t GetDefaultLimitFileSize();
|
||||
static void SetDefaultLimitFileSize(std::size_t nSize);
|
||||
//@}
|
||||
|
||||
private:
|
||||
static bool bSetDefaultLimitFileSize;
|
||||
static std::size_t nDefaultLimitFileSize;
|
||||
|
||||
private:
|
||||
std::size_t m_nCurLimitFileSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真ファイルを映像情報で読み込むクラス
|
||||
@details
|
||||
ストレージタイプと映像情報を指定することで対象となる映像ファイルを読み込みます。
|
||||
対象ファイルのサイズが事前に設定されている制限サイズを超えている場合は、読み
|
||||
込みが失敗します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PhotoImageInfoReader : private PhotoFileReader
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] nLimFileSize 読み込み制限サイズ
|
||||
@param[in] eStoType 読み込みストレージ
|
||||
@param[in] rImgInfo 読み込み先の映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
nLimFileSizeを省略した場合は、事前に設定されているデフォルトの制限サイズ
|
||||
が適用されます。
|
||||
bTwlCompatibleはTWL互換用の領域を指定するフラグで、対象ストレージがNANDで、
|
||||
JPEGファイル時のみ意味があります(それ以外では無視されます)。falseを指定
|
||||
するとCTR領域、trueを指定するとTWL領域のパスを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
PhotoImageInfoReader(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
PhotoImageInfoReader(
|
||||
Allocator& rAllocator, std::size_t nLimFileSize,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像を読み込む
|
||||
-----------------------------------------------------------------------*/
|
||||
Result ReadImage();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込むストレージを取得する
|
||||
@return ストレージ
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageType() const { return m_eStoType; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込む映像情報を取得する
|
||||
@return 映像情報
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageInfo& GetImageInfo() const { return m_rImgInfo; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ映像データを取得する
|
||||
@return 読み込んだ映像データ
|
||||
@details
|
||||
ポインタの所有権は移りません。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetImageData() const { return GetData(); }
|
||||
void* GetImageData(){ return GetData(); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ映像データのサイズ取得する
|
||||
@return サイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetImageDataSize() const{ return GetDataSize(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだファイルサイズを取得する
|
||||
@return ファイルサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
s64 GetImageFileSize() const{ return GetFileSize(); }
|
||||
|
||||
private:
|
||||
const StorageType m_eStoType;
|
||||
const ImageInfo& m_rImgInfo;
|
||||
const bool m_bTwlCompatible;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真ファイルのヘッダ部分を映像情報で読み込むクラス
|
||||
@details
|
||||
JPEGのExif(APP1)ぐらいまでを読み込みます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PhotoHeaderImageInfoReader : private PhotoHeaderFileReader
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] eStoType 読み込みストレージ
|
||||
@param[in] rImgInfo 読み込み先の映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
bTwlCompatibleはTWL互換用の領域を指定するフラグで、対象ストレージがNANDで、
|
||||
JPEGファイル時のみ意味があります(それ以外では無視されます)。falseを指定
|
||||
するとCTR領域、trueを指定するとTWL領域のパスを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
PhotoHeaderImageInfoReader(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像を読み込む
|
||||
-----------------------------------------------------------------------*/
|
||||
Result ReadImage();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込むストレージを取得する
|
||||
@return ストレージ
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageType() const { return m_eStoType; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込む映像情報を取得する
|
||||
@return 映像情報
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageInfo& GetImageInfo() const { return m_rImgInfo; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ映像データを取得する
|
||||
@return 読み込んだ映像データ
|
||||
@details
|
||||
ポインタの所有権は移りません。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetImageData() const { return GetData(); }
|
||||
void* GetImageData(){ return GetData(); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ映像データのサイズ取得する
|
||||
@return サイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetImageDataSize() const{ return GetDataSize(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだファイルサイズを取得する
|
||||
@return ファイルサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
s64 GetImageFileSize() const{ return GetFileSize(); }
|
||||
|
||||
private:
|
||||
const StorageType m_eStoType;
|
||||
const ImageInfo& m_rImgInfo;
|
||||
const bool m_bTwlCompatible;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief モーションJPEG内のJPEG読み込みクラス
|
||||
@details
|
||||
使用前に一度だけSetLimitFileSize()を呼び出して制限サイズを指定してください。
|
||||
指定せずに使用するとアサートが発生しエラーを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class JpegInMJpegFileReader : public FileReader
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] nLimFileSize 制限ファイルサイズ
|
||||
@details
|
||||
nLimFileSizeを省略した場合はSetDefaultLimitFileSize()で設定されている
|
||||
デフォルトサイズが使用されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit JpegInMJpegFileReader(Allocator& rAllocator);
|
||||
JpegInMJpegFileReader(Allocator& rAllocator, std::size_t nLimFileSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegInMJpegFileReader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 制限ファイルサイズをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetLimitFileSize() const{ return m_nCurLimitFileSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デフォルトの制限ファイルサイズをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
static bool IsValidDefaultLimitFileSize();
|
||||
static std::size_t GetDefaultLimitFileSize();
|
||||
static void SetDefaultLimitFileSize(std::size_t nSize);
|
||||
//@}
|
||||
|
||||
private:
|
||||
static bool bSetDefaultLimitFileSize;
|
||||
static std::size_t nDefaultLimitFileSize;
|
||||
|
||||
private:
|
||||
std::size_t m_nCurLimitFileSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_FILE_READER_H_
|
||||
@ -0,0 +1,560 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbFileUtility.h
|
||||
|
||||
ファイル関連ユーティリティ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_FILE_UTILITY_H_
|
||||
#define IMAGE_DB_FILE_UTILITY_H_
|
||||
|
||||
#include <nn/fs.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbDynamicArray.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbResult.h"
|
||||
#include "ImageDbIndexInfo.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
#include "ImageDbPathUtility.h"
|
||||
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct FileIndexInfo
|
||||
{
|
||||
public:
|
||||
union{
|
||||
u32 nValue;
|
||||
struct{
|
||||
u32 nNo:14; // ファイル番号(9999まで対応)
|
||||
u32 nImageKind:3; // 映像データの種類 ImageKind列挙型
|
||||
u32 reserved:15;
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
void Initialize(){ nValue = 0; }
|
||||
|
||||
int GetNo() const { return nNo; }
|
||||
void SetNo(int nNo){ this->nNo = nNo; }
|
||||
|
||||
ImageKind GetImageKind() const { return static_cast<ImageKind>(nImageKind); }
|
||||
void SetImageKind(ImageKind eImgKind){ nImageKind = eImgKind; }
|
||||
|
||||
bool operator==(const FileIndexInfo& x) const{ return (nValue == x.nValue); }
|
||||
bool operator!=(const FileIndexInfo& x) const{ return operator==(x); }
|
||||
bool operator<(const FileIndexInfo& x) const{ return (nNo < x.nNo); }
|
||||
bool operator<=(const FileIndexInfo& x) const{ return (nNo <= x.nNo); }
|
||||
bool operator>(const FileIndexInfo& x) const{ return !operator<=(x); }
|
||||
bool operator>=(const FileIndexInfo& x) const{ return !operator<(x); }
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
ImageDbが扱うDCF準拠のディレクトリの有無を記録するクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
class DcfDirectoriesEntity
|
||||
{
|
||||
public:
|
||||
/*-----------------------------------------------------------------------
|
||||
コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
DcfDirectoriesEntity(){ std::memset(m_nBit, 0, sizeof(m_nBit)); }
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
エンティティフラグを取得/設定する
|
||||
nIndex DCFディレクトリインデックス [0,899]
|
||||
nNo DCFディレクトリ番号 [100,999]
|
||||
範囲外を指定した場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetValidFlag(int nIndex) const{
|
||||
NN_ASSERT(IndexInfo::IsValidDirectoryIndex(nIndex));
|
||||
return (m_nBit[ElementTypeValidFlag][ComputeArrayIndex(nIndex)] & ComputeBitFlag(nIndex));
|
||||
}
|
||||
bool GetValidFlagByDcf(int nNo) const{
|
||||
return GetValidFlag(IndexInfo::ConvDirectoryIndexFromDcf(nNo));
|
||||
}
|
||||
void SetValidFlag(int nIndex, bool bValid){
|
||||
NN_ASSERT(IndexInfo::IsValidDirectoryIndex(nIndex));
|
||||
if(bValid){ m_nBit[ElementTypeValidFlag][ComputeArrayIndex(nIndex)] |= ComputeBitFlag(nIndex); }
|
||||
else{ m_nBit[ElementTypeValidFlag][ComputeArrayIndex(nIndex)] &= ~ComputeBitFlag(nIndex); }
|
||||
}
|
||||
void SetValidFlagByDcf(int nNo, bool bValid){
|
||||
SetValidFlag(IndexInfo::ConvDirectoryIndexFromDcf(nNo), bValid);
|
||||
}
|
||||
|
||||
|
||||
bool GetOfficialFlag(int nIndex) const{
|
||||
NN_ASSERT(IndexInfo::IsValidDirectoryIndex(nIndex));
|
||||
return (m_nBit[ElementTypeOfficialFlag][ComputeArrayIndex(nIndex)] & ComputeBitFlag(nIndex));
|
||||
}
|
||||
bool GetOfficialFlagByDcf(int nNo) const{
|
||||
return GetOfficialFlag(IndexInfo::ConvDirectoryIndexFromDcf(nNo));
|
||||
}
|
||||
void SetOfficialFlag(int nIndex, bool bValid){
|
||||
NN_ASSERT(IndexInfo::IsValidDirectoryIndex(nIndex));
|
||||
if(bValid){ m_nBit[ElementTypeOfficialFlag][ComputeArrayIndex(nIndex)] |= ComputeBitFlag(nIndex); }
|
||||
else{ m_nBit[ElementTypeOfficialFlag][ComputeArrayIndex(nIndex)] &= ~ComputeBitFlag(nIndex); }
|
||||
}
|
||||
void SetOfficialFlagByDcf(int nNo, bool bValid){
|
||||
SetOfficialFlag(IndexInfo::ConvDirectoryIndexFromDcf(nNo), bValid);
|
||||
}
|
||||
|
||||
private:
|
||||
int ComputeArrayIndex(int nIndex) const{ return nIndex / 8; }
|
||||
int ComputeBitFlag(int nIndex) const{ return 1 << (nIndex % 8); }
|
||||
|
||||
private:
|
||||
enum ElementType {
|
||||
ElementTypeValidFlag = 0,
|
||||
ElementTypeOfficialFlag,
|
||||
|
||||
ElementTypeNum
|
||||
};
|
||||
|
||||
u8 m_nBit[ElementTypeNum][(IndexInfo::c_nDirectoryIndexMax+7)/8];
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
ImageDbが扱うDCF準拠のファイルの有無を記録するクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
class DcfFilesEntity
|
||||
{
|
||||
public:
|
||||
/*-----------------------------------------------------------------------
|
||||
コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
DcfFilesEntity(){ std::memset(m_nBit, 0, sizeof(m_nBit)); }
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
エンティティフラグを取得/設定する
|
||||
nIndex DCFファイルインデックス [0,99]
|
||||
nNo DCFファイル番号 [1,100]
|
||||
範囲外を指定した場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetValidFlag(int nIndex) const{
|
||||
NN_ASSERT(IndexInfo::IsValidFileIndex(nIndex));
|
||||
return (m_nBit[ComputeArrayIndex(nIndex)] & ComputeBitFlag(nIndex));
|
||||
}
|
||||
bool GetValidFlagByDcf(int nNo) const{
|
||||
return GetValidFlag(IndexInfo::ConvFileIndexFromDcf(nNo));
|
||||
}
|
||||
void SetValidFlag(int nIndex, bool bValid){
|
||||
NN_ASSERT(IndexInfo::IsValidFileIndex(nIndex));
|
||||
if(bValid){ m_nBit[ComputeArrayIndex(nIndex)] |= ComputeBitFlag(nIndex); }
|
||||
else{ m_nBit[ComputeArrayIndex(nIndex)] &= ~ComputeBitFlag(nIndex); }
|
||||
}
|
||||
void SetValidFlagByDcf(int nNo, bool bValid){
|
||||
SetValidFlag(IndexInfo::ConvFileIndexFromDcf(nNo), bValid);
|
||||
}
|
||||
|
||||
private:
|
||||
int ComputeArrayIndex(int nIndex) const{ return nIndex / 8; }
|
||||
int ComputeBitFlag(int nIndex) const{ return 1 << (nIndex % 8); }
|
||||
|
||||
private:
|
||||
u8 m_nBit[(IndexInfo::c_nOfficialFileIndexMax+7)/8];
|
||||
};
|
||||
|
||||
|
||||
typedef DynamicArray< int, XAllocator<int> > DirectoryIndexList;
|
||||
typedef DynamicArray< FileIndexInfo, XAllocator<FileIndexInfo> > FileIndexList;
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief NANDのファイル操作失敗によるFATALエラー呼び出しを処理する
|
||||
@param[in] ret NAND操作結果
|
||||
@return 引数のretそのもの
|
||||
@details
|
||||
retにはNAND操作(FSのファイルオープンやリードライトなど)の結果を指定します。
|
||||
もしこの結果が通常ではありえない場合はFATALが発動します。
|
||||
通常のあり得るエラーや、エラーでない場合は何も行いません。
|
||||
*---------------------------------------------------------------------------*/
|
||||
nn::Result ThrowFatalErrByNandOperation(nn::Result ret);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
対象ストレージに映像データの痕跡があるかチェックする
|
||||
@return 痕跡があった場合はtrue
|
||||
@details
|
||||
「DCIM」ディレクトリがある場合は痕跡ありと判断されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsExistImageDataEvidence(StorageType eStoType);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真管理ファイルが読み取り専用になっているかチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@return 読み取り専用ならtrue
|
||||
@details
|
||||
管理ファイルが存在しないなどで確認できない場合はfalseを返します。
|
||||
NANDに読み取り専用は無いのでfalseしか返しません。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsDbFileReadOnly(StorageType eStoType);
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ディレクトリを作成する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pDirPath ディレクトリのパス
|
||||
@details
|
||||
指定ディレクトリを一括で作成します。
|
||||
既に存在する場合は何もせずに成功として扱います。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result CreateDirectory(StorageType eStoType, const wchar_t* pDirPath, Allocator* pAllocator=0);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイルを削除する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath 削除するファイルのパス
|
||||
@return 削除に成功した場合はtrue
|
||||
@details
|
||||
ファイルが存在しなかった場合は何もせずに成功と扱います。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result DeleteFile(StorageType eStoType, const wchar_t* pPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ディレクトリを削除する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pDirPath 削除するディレクトリのパス
|
||||
@return 削除に成功した場合はtrue
|
||||
@details
|
||||
ディレクトリ内にファイルが残っていても削除できます。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result DeleteDirectory(StorageType eStoType, const wchar_t* pDirPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイルが存在するかチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath チェックするファイルのパス
|
||||
@return 存在した場合はtrue
|
||||
@details
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsExistFile(StorageType eStoType, const wchar_t* pPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ディレクトリが存在するかチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pDirPath チェックするディレクトリのパス
|
||||
@return 存在した場合はtrue
|
||||
@details
|
||||
パスの最後にバックスラッシュをつけないでください。
|
||||
ディレクトリ自体が存在しない場合はfalseを返します。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsExistDir(StorageType eStoType, const wchar_t* pDirPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ディレクトリ内にファイルが存在するかチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pDirPath チェックするディレクトリのパス
|
||||
@return 存在した場合はtrue
|
||||
@details
|
||||
パスの最後にバックスラッシュをつけないでください。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsExistDirContents(StorageType eStoType, const wchar_t* pDirPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイルサイズを取得する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath 取得するファイルのパス
|
||||
@param[out] pIsAvailable ファイル利用可能フラグ(ヌル可)
|
||||
@return ファイルサイズ
|
||||
@details
|
||||
サイズの取得に失敗した場合はゼロを返します。
|
||||
ファイルが存在しない、オープン出来ないなどでサイズが取得できなかった場合は
|
||||
pIsAvailableにfalseが格納されます。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
s64 GetFileSize(StorageType eStoType, const wchar_t* pPath, bool* pIsAvailable=0);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイルの属性情報を取得する
|
||||
@param[out] rAttrib 属性情報
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath 取得するファイルのパス
|
||||
@return 取得できた場合はtrue
|
||||
@details
|
||||
eStoTypeにSDカード以外を指定した場合、rAttrib::isDirectory以外はfalseとなります。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool GetFileAttribute(
|
||||
nn::fs::Attributes& rAttrib, StorageType eStoType, const wchar_t* pPath);
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ディレクトリの属性情報を取得する
|
||||
@param[out] rAttrib 属性情報
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath 取得するディレクトリのパス
|
||||
@return 取得できた場合はtrue
|
||||
@details
|
||||
パスの最後にバックスラッシュをつけないでください。
|
||||
eStoTypeにSDカード以外を指定した場合、rAttrib::isDirectory以外はfalseとなります。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool GetDirectoryAttribute(
|
||||
nn::fs::Attributes& rAttrib, StorageType eStoType, const wchar_t* pPath);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief 指定のインデックス情報のディレクトリが利用可能かチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rIdxInfo 対象インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 利用可能な場合はtrue
|
||||
@details
|
||||
rIdxInfoから求まる映像のディレクトリ名が既に存在する、または作成可能な場合
|
||||
はtrueを返します。
|
||||
まだディレクトリが存在せず、そのディレクトリの先頭3文字の数字が既に使用さ
|
||||
れている場合は利用不可のためfalseを返します。
|
||||
(DCF仕様として先頭3文字の数字が重複してはならない)
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsAvailableIndexInfoDirectory(
|
||||
StorageType eStoType, const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief 指定のインデックス情報のファイルが利用可能かチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rIdxInfo 対象インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 利用可能な場合はtrue
|
||||
@details
|
||||
rIdxInfoから求まる映像のディレクトリに、同様に求まるファイル名が存在しない
|
||||
場合はtrueを返します。
|
||||
ディレクトリが存在しなかったり、同じファイル名が存在した場合はfalseを返しま
|
||||
す。
|
||||
(DCF仕様として末尾4文字の数字が重複してはならない)
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsAvailableIndexInfoFile(
|
||||
StorageType eStoType, const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief 指定のインデックス情報が利用可能かチェックする
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rIdxInfo 対象インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 空きの場合はtrue
|
||||
@details
|
||||
eImgKindとrIdxInfoから求まるファイル名が使用可能か、対象ストレージのフォルダ
|
||||
やファイルの名前を調べます。
|
||||
既に同じ名前のファイルがあったりして使えない場合はfalseを返します。
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
IsAvailableIndexInfoDirectory()とIsAvailableIndexInfoFile()を組み合わせた
|
||||
関数です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsAvailableIndexInfo(
|
||||
StorageType eStoType, const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief 利用可能なインテックス情報を探す
|
||||
@param[out] rIdxInfo 利用可能インデックス情報
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@param[in] rStartIdxInfo 検索開始位置
|
||||
@return 見つかればtrue
|
||||
指定ストレージの検索し、ファイル名として使用できるDCFのディレクトリ、ファイ
|
||||
ル番号を調べます。
|
||||
rStartIdxInfoを指定した場合は、その情報から空きを探します(指定しなければ最
|
||||
初から)。
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
rIdxInfoとrStartIdxInfoは同一のデータを指定することが可能です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool FindAvailableIndexInfo(
|
||||
IndexInfo& rIdxInfo, StorageType eStoType, bool bTwlCompatible);
|
||||
bool FindAvailableIndexInfo(
|
||||
IndexInfo& rIdxInfo, StorageType eStoType, bool bTwlCompatible,
|
||||
const IndexInfo& rStartIdxInfo);
|
||||
//@}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief CTR-NANDとTWL-NANDから利用可能なインテックス情報を探す
|
||||
@param[out] rIdxInfo 利用可能インデックス情報
|
||||
@param[in] rStartIdxInfo 検索開始位置
|
||||
@return 見つかればtrue
|
||||
CTR-NANDとTWL-NANDの両方で利用可能な、ファイル名として使用できるDCFのディレ
|
||||
クトリ、ファイル番号を調べます。
|
||||
rStartIdxInfoを指定した場合は、その情報から空きを探します(指定しなければ最
|
||||
初から)。
|
||||
rIdxInfoとrStartIdxInfoは同一のデータを指定することが可能です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool FindAvailableIndexInfoInNand(IndexInfo& rIdxInfo);
|
||||
bool FindAvailableIndexInfoInNand(IndexInfo& rIdxInfo, const IndexInfo& rStartIdxInfo);
|
||||
//@}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief 存在する映像ディレクトリ(100NIN02~999NIN02)を列挙する
|
||||
@param[out] rList 見つかった映像ディレクトリの番号のリスト(昇順並び)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pDirPath 列挙するディレクトリのパス
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@details
|
||||
bTwlCompatible=trueの場合は100NIN02~999NIN02、falseの場合は100NIN03~999NIN03
|
||||
のディレクトリを列挙します。
|
||||
pDirPathの末尾にスラッシュはつけないでください。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void EnumImageDirectory(DirectoryIndexList& rList, StorageType eStoType, const wchar_t* pDirPath, bool bTwlCompatible);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@brief 存在する映像ファイル(HNI_0001.XXX~HNI_0100.XXX)を列挙する
|
||||
@param[out] rList 見つかった映像ファイルの番号部分のリスト(昇順並び)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pDirPath 列挙するディレクトリのパス
|
||||
@param[in] eImgKind 列挙するファイルタイプ
|
||||
@param[in] eImgKindBit 列挙するファイルタイプビット
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@details
|
||||
pDirPathの末尾にスラッシュはつけないでください。
|
||||
eImgKindBitで複数の映像を指定して、同じファイル番号の映像が見つかった場合、
|
||||
基本はFSで最初に見つかった映像が優先されます。ただしJPEGの場合は他に違う
|
||||
映像が見つかったら上書きされます(MPOと対となるJPEGの場合、MPOが優先される)。
|
||||
bTwlCompatibleは現状意味がありません。
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpDirPathと同じストレージ
|
||||
を指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
void EnumImageFile(FileIndexList& rList, StorageType eStoType, const wchar_t* pDirPath, ImageKind eKind, bool bTwlCompatible);
|
||||
void EnumImageFile(FileIndexList& rList, StorageType eStoType, const wchar_t* pDirPath, ImageKindBit eImgKindBit, bool bTwlCompatible);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像ファイルを保存する
|
||||
@param[in] eStoType 保存先ストレージ
|
||||
@param[in] rImgInfo 保存する映像情報
|
||||
@param[in] pImgData1 保存映像1のデータ
|
||||
@param[in] nImgDataSize1 保存映像1のデータサイズ
|
||||
@param[in] pImgData2 保存映像2のデータ
|
||||
@param[in] nImgDataSize2 保存映像2のデータサイズ
|
||||
@param[in] pMpData MPデータ
|
||||
@param[in] nMpDataSize MPデータサイズ
|
||||
@param[in] pJpegData JPEGデータ
|
||||
@param[in] nJpegDataSize JPEGデータサイズ
|
||||
@return 保存結果
|
||||
@details
|
||||
この関数はファイルを保存するだけで管理ファイルへの登録などは一切行いません。
|
||||
|
||||
SaveImage()はrImgRecの情報を元にJPEGであればData1にJPEGデータ、MPであれば
|
||||
Data1にMPデータ、Data2に対となるJPEGデータと解釈します。
|
||||
MPデータ時にData2の指定がなければ、MPデータからJPEGデータを作り出します。
|
||||
|
||||
SaveImageMp()はJPEGデータの指定がなければ、MPデータからJPEGデータを作り出します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
Result SaveImage(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo,
|
||||
const void* pImgData1, std::size_t nImgDataSize1,
|
||||
const void* pImgData2, std::size_t nImgDataSize2);
|
||||
Result SaveImageJpeg(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo,
|
||||
const void* pJpegData, std::size_t nJpegDataSize);
|
||||
Result SaveImageMp(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo,
|
||||
const void* pMpData, std::size_t nMpDataSize,
|
||||
const void* pJpegData, std::size_t nJpegDataSize);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像ファイルを削除する
|
||||
@param[in] eStoType 削除先ストレージ
|
||||
@param[in] rImgRec 削除する映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@param[in] bDeleteDirectory 空ディレクトリ削除フラグ
|
||||
@details
|
||||
この関数はファイルを削除するだけで管理ファイルからの削除などは一切行いません。
|
||||
bDeleteDirectory=trueなら、ファイル削除後、フォルダが空であればフォルダを削
|
||||
除します。
|
||||
削除する写真が無かった場合は何もせずにResultSuccessを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
// 指定の映像情報のファイルを削除する
|
||||
// 内部で映像の種類を判断してそれぞれにあった削除関数を呼び出します。
|
||||
Result DeleteImage(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bDeleteDirectory=true);
|
||||
// 指定のJPEGファイルを削除する(JPEG以外を指定するとアサート)
|
||||
// NANDであればTWL側も削除します。
|
||||
Result DeleteImageJpeg(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bDeleteDirectory=true);
|
||||
// 指定のMPOファイルを削除する(MPO以外を指定するとアサート)
|
||||
// 対となるJPEGも削除します。
|
||||
Result DeleteImageMp(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bDeleteDirectory=true);
|
||||
// 指定のモーションJPEGファイルを削除する(モーションJPEG以外を指定するとアサート)
|
||||
Result DeleteImageMotionJpeg(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bDeleteDirectory=true);
|
||||
// 指定映像のTWL側だけ削除する
|
||||
// NANDが対象の場合TWL-NAND側の写真だけを削除します。
|
||||
// SDが対象の場合はDeleteImage()と処理は変わりません。
|
||||
Result DeleteImageTwl(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bDeleteDirectory=true);
|
||||
// NANDが対象の場合CTR-NAND側の写真だけを削除します。
|
||||
// SDが対象の場合はDeleteImage()と処理は変わりません。
|
||||
Result DeleteImageCtr(
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bDeleteDirectory=true);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief TWL-NAND領域にあるPNOTE関連のデータをすべて削除する
|
||||
@details
|
||||
private、DCIMディレクトリが削除されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void CleanupTwlNand();
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief CTR-NAND領域にあるPNOTE関連のデータをすべて削除する
|
||||
@details
|
||||
private、DCIMディレクトリが削除されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void CleanupCtrNand();
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief SDカードにあるPNOTE関連のデータをすべて削除する
|
||||
@details
|
||||
private、DCIMディレクトリが削除されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void CleanupSd();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 指定ディレクトリ以下のデータをすべてコピーする
|
||||
@param[in] eStoTypeSrc コピー元ストレージ
|
||||
@param[in] pSrcDir コピー元のパス
|
||||
@param[in] eStoTypeDst コピー先ストレージ
|
||||
@param[in] pDstDir コピー先のパス
|
||||
@details
|
||||
パスの末尾にスラッシュはつけないでください(例:"sdmc:/DCIM")。
|
||||
ただしルートパスを指定する場合は末尾のスラッシュは必要です(例:"sdmc:/")。
|
||||
eStoTypeSrcやeStoTypeDstはエラーが起こった時の扱いに使用されます。必ずパス
|
||||
と同じストレージを指定してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool CopyAll(
|
||||
StorageType eStoTypeSrc, const wchar_t* pSrcDir,
|
||||
StorageType eStoTypeDst, const wchar_t* pDstDir);
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_FILE_UTILITY_H_
|
||||
@ -0,0 +1,162 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbFileWriter.h
|
||||
|
||||
ファイル書き込み
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_FILE_WRITER_H_
|
||||
#define IMAGE_DB_FILE_WRITER_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbResult.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイル読み込みクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class FileWriter : private nn::util::NonCopyable<FileWriter>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
-----------------------------------------------------------------------*/
|
||||
explicit FileWriter(Allocator& rAllocator);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~FileWriter();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き込む
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath ファイルパス
|
||||
@param[in] pData データ
|
||||
@param[in] nDataSize データサイズ
|
||||
@return 成功した場合はtrue
|
||||
@details
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じスト
|
||||
レージを指定してください。
|
||||
既に同じファイルが存在する場合は上書きされます。
|
||||
ディレクトリは作成しないため、予め作成しておいてください。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Write(
|
||||
StorageType eStoType, const wchar_t* pPath,
|
||||
const void* pData, std::size_t nDataSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 結果を取得する
|
||||
@return 結果
|
||||
-----------------------------------------------------------------------*/
|
||||
Result GetResult() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief FSライブラリが返す結果を取得する
|
||||
@return 結果
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::Result GetNnResult() const;
|
||||
|
||||
protected:
|
||||
void* Alloc(std::size_t nSize);
|
||||
void Free(void* pAddr);
|
||||
|
||||
private:
|
||||
Allocator& m_rAllocator;
|
||||
|
||||
Result m_eResult;
|
||||
nn::Result m_NnResult;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像ファイル書き込みクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageFileWriter : private FileWriter
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] eStoType 書き込み先ストレージ
|
||||
@param[in] rImgInfo 書き込み先の映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@param[in] pImgData 書き込む映像データ
|
||||
@param[in] nImgSize 映像データのサイズ
|
||||
@details
|
||||
bTwlCompatibleはTWL互換用の領域を指定するフラグで、対象ストレージがNANDで、
|
||||
JPEGファイル時のみ意味があります(それ以外では無視されます)。falseを指定
|
||||
するとCTR領域、trueを指定するとTWL領域のパスを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageFileWriter(
|
||||
Allocator& rAllocator,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible,
|
||||
const void* pImgData, std::size_t nImgSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像を書き込む
|
||||
@details
|
||||
ディレクトリが存在しなければ自動で生成します。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result WriteImage();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き込むストレージを取得する
|
||||
@return ストレージ
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageType() const { return m_eStoType; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き込む映像情報を取得する
|
||||
@return 映像情報
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageInfo& GetImageInfo() const { return m_rImgInfo; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief TWL互換フラグを取得する
|
||||
@return TWL互換フラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsTwlCompatible() const { return m_bTwlCompatible; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き込む映像データを取得する
|
||||
@return 映像データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetImageData() const { return m_pImgData; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き込む映像データのサイズを取得する
|
||||
@return サイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetImageDataSize() const { return m_nImgSize; }
|
||||
|
||||
private:
|
||||
const StorageType m_eStoType;
|
||||
const ImageInfo& m_rImgInfo;
|
||||
const bool m_bTwlCompatible;
|
||||
const void* m_pImgData;
|
||||
const std::size_t m_nImgSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_FILE_WRITER_H_
|
||||
@ -0,0 +1,472 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbImageCollector.h
|
||||
|
||||
映像コレクター
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_IMAGE_COLLECTOR_H_
|
||||
#define IMAGE_DB_IMAGE_COLLECTOR_H_
|
||||
|
||||
#include <functional>
|
||||
#include <nn/types.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbImageSearcher.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief コレクションレコード情報(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
#pragma pack(push, 4)
|
||||
struct ImageCollectionTableRecord
|
||||
{
|
||||
public:
|
||||
// レコードステート列挙型
|
||||
enum State {
|
||||
StateEmpty = 0, //!< 空きレコード
|
||||
|
||||
StateExistence, //!< 既存レコード
|
||||
StateNew, //!< 新規追加レコード
|
||||
StateLostFile, //!< ファイルが無くなったレコード
|
||||
StateChangeMp2Jpg, //!< MPからJPEGに変更されたレコード
|
||||
StateChangeJpg2Mp, //!< JPEGからMPに変更されたレコード
|
||||
StateChangeFile, //!< 拡張子はそのままでファイルが挿し替わっているレコード
|
||||
|
||||
StateNum
|
||||
};
|
||||
|
||||
// レコードステート列挙型
|
||||
enum StateBit {
|
||||
StateBitEmpty = 1 << StateEmpty,
|
||||
|
||||
StateBitExistence = 1 << StateExistence,
|
||||
StateBitNew = 1 << StateNew,
|
||||
StateBitLostFile = 1 << StateLostFile,
|
||||
StateBitChangeMp2Jpg = 1 << StateChangeMp2Jpg,
|
||||
StateBitChangeJpg2Mp = 1 << StateChangeJpg2Mp,
|
||||
StateBitChangeFile = 1 << StateChangeFile,
|
||||
|
||||
StateBitAllWithoutEmypty = StateBitExistence
|
||||
| StateBitNew
|
||||
| StateBitLostFile
|
||||
| StateBitChangeMp2Jpg
|
||||
| StateBitChangeJpg2Mp
|
||||
| StateBitChangeFile,
|
||||
|
||||
StateBitAll = StateBitEmpty
|
||||
| StateBitAllWithoutEmypty
|
||||
};
|
||||
|
||||
public:
|
||||
DateTimeSeconds sShotSeconds; // 撮影日時
|
||||
char cExt[Const::c_nMaxExtLength]; //!< 拡張子
|
||||
char cFileName[Const::c_nImageFileNameLength]; //!< ファイル名
|
||||
char cDirName[Const::c_nImageDirectoryLength]; //!< ディレクトリ名
|
||||
u32 nField;
|
||||
u32 nFileSize;
|
||||
|
||||
//----- フィールド -----//
|
||||
// bit0-2 レコードステート列挙型
|
||||
static const int c_nFieldStateBits = 3;
|
||||
static const int c_nFieldStateShift = 0;
|
||||
static const u32 c_nFieldStateMask = ((1UL<<c_nFieldStateBits)-1)<<c_nFieldStateShift;
|
||||
|
||||
// bit3 オフィシャル映像フラグ
|
||||
static const int c_nFieldOfficialBits = 1;
|
||||
static const int c_nFieldOfficialShift = c_nFieldStateBits + c_nFieldStateShift;
|
||||
static const u32 c_nFieldOfficialMask = ((1UL<<c_nFieldOfficialBits)-1)<<c_nFieldOfficialShift;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 状態を取得/取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
State GetState() const;
|
||||
void SetState(State eState);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief オフィシャル映像フラグを取得/取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetOfficialFlag() const;
|
||||
void SetOfficialFlag(bool bOfficial);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影日時を取得/取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetShotSeconds() const{ return sShotSeconds; }
|
||||
void SetShotSeconds(const DateTimeSeconds& rSecs){ sShotSeconds = rSecs; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイルサイズを取得/取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetFileSize() const{ return nFileSize; }
|
||||
s64 GetFileSize64() const{ return static_cast<s64>(static_cast<u64>(nFileSize)); }
|
||||
void SetFileSize(s64 nSize){ nFileSize = static_cast<u32>(nSize); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 拡張子を取得する
|
||||
@details
|
||||
GetExtInternal()で返す文字列は内部で保持しているデータをそのまま返します。
|
||||
このデータはConst::c_nMaxExtLength要素数のバッファで、拡張子の文字数が
|
||||
このサイズぴったりの場合、終端記号を【含まない】文字列となります。また大
|
||||
文字小文字が入り混じっている可能性もあります。そのためこの関数を利用する
|
||||
場合は細心の注意を払ってください。
|
||||
GetExt()で取得すると、すべて大文字の終端記号を含む文字列を返します。
|
||||
nSizeにはConst::c_nMaxExtLength+1以上のサイズを指定してください。
|
||||
SetExt()で指定する文字列の長さはConst::c_nMaxExtLengthまでです。文字数を
|
||||
超えている場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetExtInternal() const{ return cExt; }
|
||||
int GetExt(char* pExt, int nSize) const;
|
||||
int GetExt(wchar_t* pExt, int nSize) const;
|
||||
void SetExt(const char* pExt);
|
||||
void SetExt(const wchar_t* pExt);
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイルの拡張子から映像の種類を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageKind GetImageKind() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル名を取得する
|
||||
@details
|
||||
GetFileNameInternal()で返す文字列は内部で保持しているデータをそのまま返
|
||||
します。このデータはConst::c_nImageFileNameLength要素数のバッファで、ファ
|
||||
イル名の文字数がこのサイズぴったりの場合、終端記号を【含まない】文字列と
|
||||
なります。また大文字小文字が入り混じっている可能性もあります。そのためこ
|
||||
の関数を利用する場合は細心の注意を払ってください。
|
||||
GetFileName()で取得すると、すべて大文字の終端記号を含む文字列を返します。
|
||||
nSizeにはConst::c_nImageFileNameLength+1以上のサイズを指定してください。
|
||||
SetFileName()で指定する文字列の長さはConst::c_nImageFileNameLength文字ま
|
||||
でです。文字数を超えている場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetFileNameInternal() const{ return cFileName; }
|
||||
int GetFileName(char* pFName, int nSize) const;
|
||||
int GetFileName(wchar_t* pFName, int nSize) const;
|
||||
void SetFileName(const char* pFName);
|
||||
void SetFileName(const wchar_t* pFName);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ名を取得する
|
||||
@details
|
||||
GetDirNameInternal()で返す文字列は内部で保持しているデータをそのまま返
|
||||
します。このデータはConst::c_nImageDirectoryLength要素数のバッファで、
|
||||
名前の文字数がこのサイズぴったりの場合、終端記号を【含まない】文字列と
|
||||
なります。また大文字小文字が入り混じっている可能性もあります。そのため
|
||||
この関数を利用する場合は細心の注意を払ってください。
|
||||
GetDirName()で取得すると、すべて大文字の終端記号を含む文字列を返します。
|
||||
nSizeにはConst::c_nImageDirectoryLength+1以上のサイズを指定してください。
|
||||
SetDirName()で指定する文字列の長さはConst::c_nImageDirectoryLength文字
|
||||
までです。文字数を超えている場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetDirectoryNameInternal() const{ return cDirName; }
|
||||
int GetDirectoryName(char* pDName, int nSize) const;
|
||||
int GetDirectoryName(wchar_t* pDName, int nSize) const;
|
||||
void SetDirectoryName(const char* pDName);
|
||||
void SetDirectoryName(const wchar_t* pDName);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像のファイルパスを生成する
|
||||
@param[out] pStr 生成したパスを格納するバッファ
|
||||
@param[in] nSize バッファのサイズ(文字数単位)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"sdmc:/DCIM/100NIN02/HNI_0001.JPG"
|
||||
バッファは Const::c_nMaxImageFileFullPathLength+1 以上のサイズが必要です。
|
||||
(文字数は変動するため少なくても動作するときはありますが非推奨)
|
||||
eRecKindは大本のディレクトリのパスの決定で使用されるもので、映像の拡張子
|
||||
などを変えるものではありません。
|
||||
-----------------------------------------------------------------------*/
|
||||
int CreateImagePath(
|
||||
wchar_t* pStr, int nSize, StorageType eStoType, bool bTwlCompatible) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 拡張子を変えて映像のファイルパスを生成する
|
||||
@param[out] pStr 生成したパスを格納するバッファ
|
||||
@param[in] nSize バッファのサイズ(文字数単位)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] eImgKind 映像の種類
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"sdmc:/DCIM/100NIN02/HNI_0001.JPG"
|
||||
バッファは Const::c_nMaxImageFileFullPathLength+1 以上のサイズが必要です。
|
||||
(文字数は変動するため少なくても動作するときはありますが非推奨)
|
||||
保持している拡張子は使わずに、eImgKindで指定された映像の拡張子が使用され
|
||||
ます。
|
||||
-----------------------------------------------------------------------*/
|
||||
int CreateImagePathWithChangeExt(
|
||||
wchar_t* pStr, int nSize,
|
||||
StorageType eStoType, ImageKind eImgKind, bool bTwlCompatible) const;
|
||||
|
||||
private:
|
||||
static int CopyBufToStr(char* pDst, int nDstSize, const char* pBufSrc, int nBufSrcSize);
|
||||
static int CopyBufToStr(wchar_t* pDst, int nDstSize, const char* pBufSrc, int nBufSrcSize);
|
||||
static void CopyStrToBuf(char* pBufDst, int nBufDstSize, const char* pSrc);
|
||||
static void CopyStrToBuf(char* pBufDst, int nBufDstSize, const wchar_t* pSrc);
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief コレクションテーブル情報
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageCollectionTable
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageCollectionTable();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~ImageCollectionTable();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief テーブルが初期化済みかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const{ return (0 != m_pAllocator); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief テーブルを初期化する
|
||||
@param[in] rAllocator クラスが使用するメモリのアロケータ
|
||||
@param[in] nRecordNum 用意するレコード数
|
||||
@details
|
||||
既に初期化済みの場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(Allocator& rAllocator, int nRecordNum);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief テーブルを解放する
|
||||
@details
|
||||
既に解放済みの場合は何もしません。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Release();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコード数を取得する
|
||||
@details
|
||||
Initialize()で指定したレコード数を返します。
|
||||
未初期化の場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ NN_ASSERT(IsInitialized()); return m_nRecordNum; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコードを取得する
|
||||
@details
|
||||
Initialize()で指定したレコード数を返します。
|
||||
未初期化の場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const ImageCollectionTableRecord& GetRecord(int nIndex) const;
|
||||
ImageCollectionTableRecord& GetRecord(int nIndex);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定状態のレコードを空きにする
|
||||
@param[in] eState 対象状態
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void ClearRecord(ImageCollectionTableRecord::State eState);
|
||||
void ClearRecord(ImageCollectionTableRecord::StateBit eStateBit);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定状態のレコードを探す
|
||||
@param[in] eState 対象状態
|
||||
@param[in] nStartIndex 検索開始位置
|
||||
@return 見つけたレコードのインデックス
|
||||
@details
|
||||
nStartIndexを指定すると、指定インデックス+1から検索を開始します。
|
||||
見つからなかった場合はマイナス値を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int FindRecord(ImageCollectionTableRecord::State eState, int nStartIndex = -1) const;
|
||||
int FindRecord(ImageCollectionTableRecord::StateBit eStateBit, int nStartIndex = -1) const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
Allocator* m_pAllocator;
|
||||
|
||||
ImageCollectionTableRecord* m_pRecords;
|
||||
int m_nRecordNum;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像コレクター
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageCollector
|
||||
{
|
||||
friend class ImageDatabase;
|
||||
|
||||
public:
|
||||
enum ProcessType {
|
||||
ProcessTypeNone = 0,
|
||||
|
||||
ProcessTypeCleanup, // 削除されたデータとファイルサイズの調査
|
||||
ProcessTypeCollectOfficial, // オフィシャルデータ(任天堂データ)の調査中
|
||||
ProcessTypeCollectUnofficial, // アンオフィシャルデータ(他社データ)の調査中
|
||||
|
||||
ProcessTypeNum
|
||||
};
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageCollector();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~ImageCollector();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化済みかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const{ return (0 != m_pAllocator); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 解放する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Release();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 対象ストレージを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageType() const{ return m_eStoType; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 処理を開始する
|
||||
@param[in] eProcType 行う処理
|
||||
@details
|
||||
処理開始以降はUpdateを呼び出して処理を更新してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void StartProcess(ProcessType eProcType);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 処理を更新する
|
||||
@details
|
||||
毎フレーム呼び出してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Update();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 処理更新により変更があったかチェックする
|
||||
@details
|
||||
Update()を呼び出すことで変更されることがあります。
|
||||
一度ダーティ状態になったらResetDirty()を呼び出すまでそのままです。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsDirty() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 処理更新による変更状態をリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetDirty();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在のプロセスタイプを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
ProcessType GetProcessType() const{ return m_eProcType; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief テーブルを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const ImageCollectionTable& GetTable() const{ return m_Table; }
|
||||
ImageCollectionTable& GetTable(){
|
||||
return const_cast<ImageCollectionTable&>(static_cast<const ImageCollector&>(*this).GetTable()); }
|
||||
//@}
|
||||
|
||||
private:
|
||||
void Initialize(Allocator& rAllocator, StorageType eStoType);
|
||||
|
||||
void SetDirty();
|
||||
|
||||
int FindSameInfoInTable(const ImageInfo& rImgInfo) const;
|
||||
|
||||
void ChangeProcess(ProcessType eProcType);
|
||||
|
||||
void InitProcessNone(){}
|
||||
void EndProcessNone(){}
|
||||
void UpdateProcessNone(){}
|
||||
|
||||
void InitProcessCleanup();
|
||||
void EndProcessCleanup();
|
||||
void UpdateProcessCleanup();
|
||||
|
||||
void InitProcessCollectOfficial();
|
||||
void EndProcessCollectOfficial();
|
||||
void UpdateProcessCollectOfficial();
|
||||
|
||||
void InitProcessCollectUnofficial();
|
||||
void EndProcessCollectUnofficial();
|
||||
void UpdateProcessCollectUnofficial();
|
||||
|
||||
private:
|
||||
// プロセス初期化処理テーブル
|
||||
static const std::mem_fun_t<void, ImageCollector> c_fnInitProcessTable[ProcessTypeNum];
|
||||
// プロセス終了処理テーブル
|
||||
static const std::mem_fun_t<void, ImageCollector> c_fnEndProcessTable[ProcessTypeNum];
|
||||
// プロセス更新処理テーブル
|
||||
static const std::mem_fun_t<void, ImageCollector> c_fnUpdateProcessTable[ProcessTypeNum];
|
||||
|
||||
private:
|
||||
Allocator* m_pAllocator;
|
||||
StorageType m_eStoType;
|
||||
ImageCollectionTable m_Table;
|
||||
bool m_bDirty;
|
||||
|
||||
ProcessType m_eProcType;
|
||||
|
||||
int m_nCleanupIndex;
|
||||
|
||||
ImageSearcher* m_pSearcher;
|
||||
bool m_bFoundDir;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
|
||||
#endif // IMAGE_DB_IMAGE_COLLECTOR_H_
|
||||
@ -0,0 +1,341 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbImageInfo.h
|
||||
|
||||
映像情報
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_IMAGE_INFO_H_
|
||||
#define IMAGE_DB_IMAGE_INFO_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbIndexInfo.h"
|
||||
#include "ImageDbDateTimeSeconds.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像情報データ構造体(POD)
|
||||
@details
|
||||
PNOTE独自で保持する情報
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
#pragma pack(push, 4)
|
||||
struct ImageInfo
|
||||
{
|
||||
public:
|
||||
//! 本体ID最大数
|
||||
static const int c_nIdMaxNum = 4;
|
||||
|
||||
//----- フラグA -----//
|
||||
// bit0 有効フラグ
|
||||
static const int c_nFlagAValidBits = 1;
|
||||
static const int c_nFlagAValidShift = 0;
|
||||
static const u32 c_nFlagAValidMask = ((1UL<<c_nFlagAValidBits)-1)<<c_nFlagAValidShift;
|
||||
|
||||
// bit1-8 取り扱いフラグ
|
||||
static const int c_nFlagAHandleTypeBitBits = imgdb::HandleTypeMax; // 8
|
||||
static const int c_nFlagAHandleTypeBitShift = c_nFlagAValidBits + c_nFlagAValidShift; // 1
|
||||
static const u32 c_nFlagAHandleTypeBitMask = ((1UL<<c_nFlagAHandleTypeBitBits)-1)<<c_nFlagAHandleTypeBitShift;
|
||||
|
||||
// bit9-16 本体IDフラグ
|
||||
static const int c_nFlagABodyIdTypeBitBits = imgdb::BodyIdTypeMax; // 8
|
||||
static const int c_nFlagABodyIdTypeBitShift = c_nFlagAHandleTypeBitBits + c_nFlagAHandleTypeBitShift; // 9
|
||||
static const u32 c_nFlagABodyIdTypeBitMask = ((1UL<<c_nFlagABodyIdTypeBitBits)-1)<<c_nFlagABodyIdTypeBitShift;
|
||||
|
||||
//----- フラグB -----//
|
||||
// bit0-5 撮影モード
|
||||
static const int c_nFlagBShootingTypeBits = 5;
|
||||
static const int c_nFlagBShootingTypeShift = 0;
|
||||
static const u32 c_nFlagBShootingTypeMask = ((1UL<<c_nFlagBShootingTypeBits)-1)<<c_nFlagBShootingTypeShift;
|
||||
|
||||
// bit6-21 写真特徴タイプフラグ
|
||||
static const int c_nFlagBDistinctionTypeBitBits = 16;
|
||||
static const int c_nFlagBDistinctionTypeBitShift = c_nFlagBShootingTypeBits + c_nFlagBShootingTypeShift; // 5
|
||||
static const u32 c_nFlagBDistinctionTypeBitMask = ((1UL<<c_nFlagBDistinctionTypeBitBits)-1)<<c_nFlagBDistinctionTypeBitShift;
|
||||
|
||||
// bit22-25 保存過程
|
||||
static const int c_nFlagBSaveProcessTypeBits = 4;
|
||||
static const int c_nFlagBSaveProcessTypeShift = c_nFlagBDistinctionTypeBitBits + c_nFlagBDistinctionTypeBitShift; // 21
|
||||
static const u32 c_nFlagBSaveProcessTypeMask = ((1UL<<c_nFlagBSaveProcessTypeBits)-1)<<c_nFlagBSaveProcessTypeShift;
|
||||
|
||||
public:
|
||||
char cExt[Const::c_nMaxExtLength]; //!< 拡張子
|
||||
char cFileName[Const::c_nImageFileNameLength]; //!< ファイル名
|
||||
char cDirName[Const::c_nImageDirectoryLength]; //!< ディレクトリ名
|
||||
DateTimeSeconds sShotSeconds; //!< 撮影日時
|
||||
DateTimeSeconds sCreateSeconds; //!< ファイル作成日時
|
||||
u32 nTitleUniqueId; //!< タイトルユニークID(ソフトウェアID)
|
||||
u32 nFlagA; //!< フラグ
|
||||
u32 nFlagB; //!< フラグ
|
||||
u32 nBodyId[c_nIdMaxNum]; //!< 本体ID
|
||||
u32 nFileSize; //!< ファイルサイズ
|
||||
int : 32; // reserve
|
||||
int : 32; // reserve
|
||||
int : 32; // reserve
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@param[in] eImgKind 初期化対象の映像種類
|
||||
@details
|
||||
eImgKindを省略すると従来通りで初期化されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void Initialize();
|
||||
void Initialize(ImageKind eImgKind);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
名前、値の範囲などをチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
ディレクトリ、ファイル名、拡張子以外の妥当性をチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidateWithoutPath() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイルの拡張子を取得/設定する
|
||||
@details
|
||||
GetExtInternal()で返す文字列は内部で保持しているデータをそのまま返します。
|
||||
このデータはConst::c_nMaxExtLength要素数のバッファで、拡張子の文字数が
|
||||
このサイズぴったりの場合、終端記号を【含まない】文字列となります。また大
|
||||
文字小文字が入り混じっている可能性もあります。そのためこの関数を利用する
|
||||
場合は細心の注意を払ってください。
|
||||
GetExt()で取得すると、すべて大文字の終端記号を含む文字列を返します。
|
||||
nSizeにはConst::c_nMaxExtLength+1以上のサイズを指定してください。
|
||||
SetExt()で指定する文字列の長さはConst::c_nMaxExtLengthまでです。文字数を
|
||||
超えている場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetExtInternal() const{ return cExt; }
|
||||
int GetExt(char* pExt, int nSize) const;
|
||||
int GetExt(wchar_t* pExt, int nSize) const;
|
||||
void SetExt(const char* pExt);
|
||||
void SetExt(const wchar_t* pExt);
|
||||
void SetExt(ImageKind eKind);
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイルの拡張子が有効かチェックする
|
||||
@return 有効ならtrue
|
||||
@details
|
||||
DCFに準拠しているかチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidateExt() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイルの拡張子から映像の種類を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
static ImageKind GetImageKind(const char* pExt);
|
||||
static ImageKind GetImageKind(const wchar_t* pExt);
|
||||
ImageKind GetImageKind() const;
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル名を取得/設定する
|
||||
@details
|
||||
GetFileNameInternal()で返す文字列は内部で保持しているデータをそのまま返
|
||||
します。このデータはConst::c_nImageFileNameLength要素数のバッファで、ファ
|
||||
イル名の文字数がこのサイズぴったりの場合、終端記号を【含まない】文字列と
|
||||
なります。また大文字小文字が入り混じっている可能性もあります。そのためこ
|
||||
の関数を利用する場合は細心の注意を払ってください。
|
||||
GetFileName()で取得すると、すべて大文字の終端記号を含む文字列を返します。
|
||||
nSizeにはConst::c_nImageFileNameLength+1以上のサイズを指定してください。
|
||||
SetFileName()で指定する文字列の長さはConst::c_nImageFileNameLength文字ま
|
||||
でです。文字数を超えている場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetFileNameInternal() const{ return cFileName; }
|
||||
int GetFileName(char* pFName, int nSize) const;
|
||||
int GetFileName(wchar_t* pFName, int nSize) const;
|
||||
void SetFileName(const char* pFName);
|
||||
void SetFileName(const wchar_t* pFName);
|
||||
void SetFileName(const IndexInfo& rIdxInfo);
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル名が有効かチェックする
|
||||
@return 有効ならtrue
|
||||
@details
|
||||
DCFに準拠しているかチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidateFileName() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル番号を取得する
|
||||
@return 取得できた場合は0~9999(普通は1~9999)
|
||||
@details
|
||||
無効な場合はマイナスの値を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetFileNo() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル番号を設定する
|
||||
@param[in] ファイル番号0~9999(普通は1~9999)
|
||||
@details
|
||||
範囲外の値が指定された場合はアサートが発生します。
|
||||
既にValidateFileName()で有効な名前が設定されている必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetFileNo(int nNo);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ名を取得/設定する
|
||||
@details
|
||||
GetDirNameInternal()で返す文字列は内部で保持しているデータをそのまま返
|
||||
します。このデータはConst::c_nImageDirectoryLength要素数のバッファで、
|
||||
名前の文字数がこのサイズぴったりの場合、終端記号を【含まない】文字列と
|
||||
なります。また大文字小文字が入り混じっている可能性もあります。そのため
|
||||
この関数を利用する場合は細心の注意を払ってください。
|
||||
GetDirName()で取得すると、すべて大文字の終端記号を含む文字列を返します。
|
||||
nSizeにはConst::c_nImageDirectoryLength+1以上のサイズを指定してください。
|
||||
SetDirName()で指定する文字列の長さはConst::c_nImageDirectoryLength文字
|
||||
までです。文字数を超えている場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetDirectoryNameInternal() const{ return cDirName; }
|
||||
int GetDirectoryName(char* pDName, int nSize) const;
|
||||
int GetDirectoryName(wchar_t* pDName, int nSize) const;
|
||||
void SetDirectoryName(const char* pDName);
|
||||
void SetDirectoryName(const wchar_t* pDName);
|
||||
void SetDirectoryName(const IndexInfo& rIdxInfo, bool bTwlCompatible=false);
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ名が有効かチェックする
|
||||
@return 有効ならtrue
|
||||
@details
|
||||
DCFに準拠しているかチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidateDirectoryName() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ番号を取得する
|
||||
@return 取得できた場合は0~999(普通は100~999)
|
||||
@details
|
||||
無効な場合はマイナスの値を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetDirectoryNo() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ番号を設定する
|
||||
@param[in] ディレクトリ番号0~999(普通は100~999)
|
||||
@details
|
||||
範囲外の値が指定された場合はアサートが発生します。
|
||||
既にValidateDirectoryName()で有効な名前が設定されている必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetDirectoryNo(int nNo);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インデックス情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
IndexInfo GetIndexInfo() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影日時を取得/設定する(2000/01/01 0:0:0からの経過秒数)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetShotSeconds() const{ return sShotSeconds; }
|
||||
void SetShotSeconds(const DateTimeSeconds& rDTSecs){ sShotSeconds = rDTSecs; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 作成日時を取得/設定する(2000/01/01 0:0:0からの経過秒数)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetCreateSeconds() const{ return sCreateSeconds; }
|
||||
void SetCreateSeconds(const DateTimeSeconds& rDTSecs){ sCreateSeconds = rDTSecs; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetTitleUniqueId() const{ return nTitleUniqueId; }
|
||||
void SetTitleUniqueId(u32 nUId){ nTitleUniqueId = nUId; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 有効フラグを取得/設定する
|
||||
@detail
|
||||
このフラグが有効な場合は、このデータには情報が入っていることになります。
|
||||
ただし入っている情報が有効なものかどうかは別問題です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetValidityFlag() const;
|
||||
void SetValidityFlag(bool bValidity);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 取り扱いフラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
HandleTypeBit GetHandleTypeBit() const;
|
||||
void SetHandleTypeBit(HandleTypeBit eBit);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 本体IDの取得/設定/チェック/リセットを行う
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetBodyId(BodyIdType eType) const;
|
||||
void SetBodyId(BodyIdType eType, u32 nId);
|
||||
bool IsValidBodyId(BodyIdType eType) const;
|
||||
BodyIdTypeBit GetValidBodyIdBit() const;
|
||||
void ResetBodyId(BodyIdType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ShootingType GetShootingType() const;
|
||||
void SetShootingType(ShootingType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真特徴タイプのビットフラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
DistinctionTypeBit GetDistinctionTypeBit() const;
|
||||
void SetDistinctionTypeBit(DistinctionTypeBit eBit);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存過程タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
SaveProcessType GetSaveProcessType() const;
|
||||
void SetSaveProcessType(SaveProcessType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイルサイズを取得/設定する(Byte単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetFileSize() const{ return nFileSize; }
|
||||
s64 GetFileSize64() const{ return static_cast<s64>(static_cast<u64>(nFileSize)); }
|
||||
void SetFileSize(u32 nSize){ nFileSize = nSize; }
|
||||
//@}
|
||||
|
||||
private:
|
||||
static int CopyBufToStr(char* pDst, int nDstSize, const char* pBufSrc, int nBufSrcSize);
|
||||
static int CopyBufToStr(wchar_t* pDst, int nDstSize, const char* pBufSrc, int nBufSrcSize);
|
||||
static void CopyStrToBuf(char* pBufDst, int nBufDstSize, const char* pSrc);
|
||||
static void CopyStrToBuf(char* pBufDst, int nBufDstSize, const wchar_t* pSrc);
|
||||
|
||||
void SetValidBodyIdBit(BodyIdTypeBit eBit);
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_IMAGE_INFO_H_
|
||||
@ -0,0 +1,135 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbImageSearcher.h
|
||||
|
||||
映像サーチオブジェクト
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_IMAGE_SEARCHER_H_
|
||||
#define IMAGE_DB_IMAGE_SEARCHER_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
#include "ImageDbDirectory.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像サーチオブジェクト
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageSearcher
|
||||
{
|
||||
public:
|
||||
// 検索ステート列挙型
|
||||
enum SearchState {
|
||||
SearchStateNone = 0, // 結果なし
|
||||
SearchStateFound, // 発見
|
||||
SearchStateSearching, // 検索中
|
||||
|
||||
SearchStateNum
|
||||
};
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ImageSearcher();
|
||||
ImageSearcher(Allocator& rAllocator, StorageType eStoType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~ImageSearcher();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化済みかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const{ return (0 != m_pAllocator); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@details
|
||||
既に初期化済みの場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(Allocator& rAllocator, StorageType eStoType);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 解放する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Release();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像ディレクトリを見つける
|
||||
@return 検索ステート
|
||||
@details
|
||||
戻り値がSearchStateFoundの場合は、DCF準拠のディレクトリを発見し、
|
||||
GetSearchedImageInfo()でその情報を取得できる状態です。
|
||||
SearchStateSearchingの場合は、まだ検索中で結果が出ていない状態で、さらに
|
||||
SearchDirectoryを呼び出すことができます。
|
||||
SearchStateNoneの場合はこれ以上検索できないときの状態です。
|
||||
-----------------------------------------------------------------------*/
|
||||
SearchState SearchDirectory();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 現在のディレクトリのファイルを見つける
|
||||
@return 見つけた場合はtrue
|
||||
@details
|
||||
戻り値がSearchStateFoundの場合は、DCF準拠のディレクトリを発見し、
|
||||
GetSearchedImageInfo()でその情報を取得できる状態です。
|
||||
SearchStateSearchingの場合は、まだ検索中で結果が出ていない状態で、さらに
|
||||
SearchDirectoryを呼び出すことができます。
|
||||
SearchStateNoneの場合はこれ以上検索できないときの状態です。
|
||||
-----------------------------------------------------------------------*/
|
||||
SearchState SearchFile();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 見つけた映像情報を取得する
|
||||
@return 映像情報
|
||||
@details
|
||||
SearchDirectory()、SearchFile()で見つけた映像情報が格納されます。
|
||||
SearchDirectory()だけを行った場合などはディレクトリ名だけが格納されてい
|
||||
ます。
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageInfo& GetSearchedImageInfo() const{ return m_sFoundImgInfo; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CTRのディレクトリ名かチェックする
|
||||
@return 映像情報
|
||||
@details
|
||||
"100NIN03"
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsCtrDirectoryName() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 任天堂関連のディレクトリ名かチェックする
|
||||
@param[out] pPostfixNo 後ろ5文字"NIN??"の後半2文字の数字(ヌル可)
|
||||
@details
|
||||
DCF3桁数字+"NIN"+2桁数字を任天堂関連と判断します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsNintendoDirectoryName(int* pPostfixNo=0) const;
|
||||
|
||||
private:
|
||||
Allocator* m_pAllocator;
|
||||
StorageType m_eStoType;
|
||||
|
||||
Directory* m_pDirDirs;
|
||||
Directory* m_pDirFiles;
|
||||
|
||||
ImageInfo m_sFoundImgInfo;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
|
||||
#endif // IMAGE_DB_IMAGE_SEARCHER_H_
|
||||
@ -0,0 +1,242 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbImageUtility.h
|
||||
|
||||
画像関連のユーティリティ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_IMAGE_UTILITY_H_
|
||||
#define IMAGE_DB_IMAGE_UTILITY_H_
|
||||
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbPictureTable.h"
|
||||
#include "ImageDbFileReader.h"
|
||||
#include "JpegMpDecoder.h"
|
||||
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
#include "../../Movie/nmjPlayer.h"
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
/*===========================================================================*
|
||||
写真関連
|
||||
*===========================================================================*/
|
||||
/*!--------------------------------------------------------------------------*
|
||||
再エンコードしたJPEGを作成する
|
||||
@param[out] rReJpegData 再エンコードしたJPEG
|
||||
@param[out] rReJpegDataSize 再エンコードしたJPEGのサイズ
|
||||
@param[in] pJpegData 再エンコードするJPEG
|
||||
@param[in] nJpegDataSize 再エンコードするJPEGのサイズ
|
||||
@param[in] rCreateSeconds 再エンコードしたJPEGの作成日時(秒単位)
|
||||
@return 成功した場合はtrue
|
||||
@details
|
||||
Exif情報は元のJPEGと同じ内容が設定されます。
|
||||
rCreateSecondsは作成したJPEGのExifに書き込まれるファイく作成日時です。
|
||||
rCreateSecondsを省略、または無効な場合は今の日時が設定されます。
|
||||
不要になったrReJpegDataはGetAllocator()->Free()する必要があります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ReEncodeJpeg(
|
||||
void*& rReJpegData, std::size_t& rReJpegDataSize,
|
||||
const void* pJpegData, std::size_t nJpegDataSize);
|
||||
bool ReEncodeJpeg(
|
||||
void*& rReJpegData, std::size_t& rReJpegDataSize,
|
||||
const void* pJpegData, std::size_t nJpegDataSize,
|
||||
const DateTimeSeconds& rCreateSeconds);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
TWL互換用の画像の仕様になっているかチェックする
|
||||
@param[in] nWidth 画像の幅(ピクセル単位)
|
||||
@param[in] nHeight 画像の高さ(ピクセル単位)
|
||||
@return TWL仕様になっているならtrue
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool CheckTwlSpec(int nWidth, int nHeight);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
JPEGからTWL互換用のJPEGを作成する
|
||||
@param[out] rTwlJpegData 作成したTWL互換JPEG
|
||||
@param[out] rTwlJpegDataSize 作成したTWL互換JPEGのサイズ
|
||||
@param[in] pJpegData 元となるJPEG
|
||||
@param[in] nJpegDataSize 元となるJPEGのサイズ
|
||||
@param[in] rCreateSeconds 作成したTWL互換JPEGの作成日時
|
||||
@return 成功した場合はtrue
|
||||
@details
|
||||
Exif情報は元のJPEGと同じ内容が設定されます。
|
||||
rCreateSecondsは作成したJPEGのExifに書き込まれるファイく作成日時です。
|
||||
rCreateSecondsを省略、または無効な場合は今の日時が設定されます。
|
||||
不要になったrTwlJpegDataはGetAllocator()->Free()する必要があります。
|
||||
TWL互換用JPEGはVGAサイズしか作成できません。それ以外のサイズの場合は失敗します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool CreateTwlJpegFromJpeg(
|
||||
void*& rTwlJpegData, std::size_t& rTwlJpegDataSize,
|
||||
const void* pJpegData, std::size_t nJpegDataSize);
|
||||
bool CreateTwlJpegFromJpeg(
|
||||
void*& rTwlJpegData, std::size_t& rTwlJpegDataSize,
|
||||
const void* pJpegData, std::size_t nJpegDataSize,
|
||||
const DateTimeSeconds& rCreateSeconds);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像ファイルから写真情報を抽出する
|
||||
@param[out] rPictTblRec 抽出した写真情報
|
||||
@param[in] pCfg 動画再生ライブラリ用コンフィグ(ヌル可)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@details
|
||||
rPictTblRecには取り出した情報のみ上書きされます(関係ないデータはそのまま)。
|
||||
必要であれば初期化したものを渡してください。
|
||||
具体的に以下の情報が格納されます。
|
||||
撮影時間
|
||||
ファイル作成時間
|
||||
タイトルユニークID
|
||||
取り扱いフラグ
|
||||
撮影タイプ
|
||||
写真特徴タイプ
|
||||
保存過程タイプ
|
||||
本体ID
|
||||
顔情報
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
pCfgについてはExtractMovieFileInfo()の説明を参照してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool ExtractPictureInfoFromFile(
|
||||
PictureTableRecord& rPictTblRec,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
bool ExtractPictureInfoFromFile(
|
||||
PictureTableRecord& rPictTblRec, nmj::player::Config* pCfg,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief Exifから写真情報を抽出する
|
||||
@param[out] rPictTblRec 抽出した写真情報
|
||||
@param[in] rDec 抽出するExifを含むデコーダ
|
||||
@details
|
||||
rPictTblRecには取り出した情報のみ上書きされます(関係ないデータはそのまま)。
|
||||
必要であれば初期化したものを渡してください。
|
||||
rDecはデコード成功直後や、ExtractExif()でExifが取得できる状態にしてください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void ExtractPictureInfoFromExif(
|
||||
PictureTableRecord& rPictTblRec, const JpegMpBaseDecoder& rDec);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像ファイルから映像レコードパラメータを抽出する
|
||||
@param[out] rImgRecParam 抽出した映像レコードパラメータ
|
||||
@param[in] eImgKind 初期化対象の映像種類
|
||||
@param[in] pCfg 動画再生ライブラリ用コンフィグ(ヌル可)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@details
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
取り出せなかった情報には初期値が代入されます。
|
||||
eImgKindを省略すると従来通りで初期化されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool ExtractRecordParamFromExif(
|
||||
ImageDbRecordParam& rImgRecParam,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
bool ExtractRecordParamFromExif(
|
||||
ImageDbRecordParam& rImgRecParam, ImageKind eImgKind,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
bool ExtractRecordParamFromExif(
|
||||
ImageDbRecordParam& rImgRecParam, nmj::player::Config* pCfg,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
bool ExtractRecordParamFromExif(
|
||||
ImageDbRecordParam& rImgRecParam, ImageKind eImgKind, nmj::player::Config* pCfg,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief Exifから映像レコードパラメータを抽出する
|
||||
@param[out] rImgRecParam 抽出した映像レコードパラメータ
|
||||
@param[in] eImgKind 初期化対象の映像種類
|
||||
@param[in] rDec 抽出するExifを含むデコーダ
|
||||
@details
|
||||
取り出せなかった情報には初期値が代入されます。
|
||||
rDecはデコード成功直後や、ExtractExif()でExifが取得できる状態にしてください。
|
||||
eImgKindを省略すると初期値を写真として初期化されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void ExtractRecordParamFromExif(
|
||||
ImageDbRecordParam& rImgRecParam, const JpegMpBaseDecoder& rDec);
|
||||
void ExtractRecordParamFromExif(
|
||||
ImageDbRecordParam& rImgRecParam, ImageKind eImgKind, const JpegMpBaseDecoder& rDec);
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
動画関連
|
||||
*===========================================================================*/
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 動画ファイル情報の中身が有効かチェックする
|
||||
@param[in] rFileInfo 対象の動画情報
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
動画ファイルの妥当性はチェックしません。
|
||||
動画ファイルの妥当性は ImageDbImageValidatorBasic を利用してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool ValidateMovieFileInfo(const nmj::player::FileInfo& rFileInfo);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 動画ファイル情報を抽出する
|
||||
@param[out] rFileInfo 抽出した動画ファイル情報
|
||||
@param[in] pCfg 動画再生ライブラリ用コンフィグ(ヌル可)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 抽出に成功した場合はtrue
|
||||
@details
|
||||
動画ファイルはSDカードでしか利用できないため、eStoTypeにNANDを指定した場合は
|
||||
無条件で失敗します。
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
|
||||
この関数で情報が取得できた場合は、ある程度再生できそうな動画ファイルととなり
|
||||
ます。
|
||||
|
||||
pCfgにヌルを指定するとデフォルトのコンフィグでファイルアクセスが行われます。
|
||||
メインスレッドで呼び出す場合はヌルで構いませんが、スレッドから呼び出す場合
|
||||
は、呼び出し側で用意した専用のコンフィグを使用し、コンフィグデータがぶつか
|
||||
らないようにする必要があります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result ExtractMovieFileInfo(
|
||||
nmj::player::FileInfo& rFileInfo, nmj::player::Config* pCfg,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief モーションJPEGからJPEGを抽出する
|
||||
@param[out] rReader 抽出したJPEGを格納するファイルリーダー
|
||||
@param[in] pCfg 動画再生ライブラリ用コンフィグ(ヌル可)
|
||||
@param[in] rFileInfo 対象の動画情報
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象の動画ファイル情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 抽出結果
|
||||
@details
|
||||
bTwlCompatible=trueの場合、NANDであればTWL-NANDをチェックします。
|
||||
SDの場合はどの値でも無視されます。
|
||||
抽出したJPEGの妥当性はチェックしません。
|
||||
直接pPathを指定するタイプでは必ずSDカードのパスを指定することを保証してください。
|
||||
pCfgについてはExtractMovieFileInfo()の説明を参照してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result ExtractJpegFromMJpeg(
|
||||
JpegInMJpegFileReader& rReader, nmj::player::Config* pCfg,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
Result ExtractJpegFromMJpeg(
|
||||
JpegInMJpegFileReader& rReader, const nmj::player::FileInfo& rFileInfo,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
Result ExtractJpegFromMJpeg(
|
||||
JpegInMJpegFileReader& rReader, const nmj::player::FileInfo& rFileInfo,
|
||||
const wchar_t* pPath);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_IMAGE_UTILITY_H_
|
||||
@ -0,0 +1,165 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbImageValidator.h
|
||||
|
||||
映像検証
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_IMAGE_VALIDATOR_H_
|
||||
#define IMAGE_DB_IMAGE_VALIDATOR_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
#include "../../Movie/nmjPlayer.h"
|
||||
#endif // IMAGE_DB_IMAGE_UTILITY_H_
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像の妥当性の簡易検証クラス
|
||||
@details
|
||||
映像のヘッダ部だけで妥当性をチェックします。
|
||||
映像全体をチェックするわけではないので、完全な検証ではありません。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageDbImageValidatorBasic : private nn::util::NonCopyable<ImageDbImageValidatorBasic>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageDbImageValidatorBasic();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~ImageDbImageValidatorBasic();
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の妥当性を検証する
|
||||
@param[in] pCfg 動画再生ライブラリ用コンフィグ(ヌル可)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 妥当ならtrue
|
||||
@details
|
||||
pCfgについてはExtractMovieFileInfo()の説明を参照してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ValidateImage(StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
bool ValidateImage(nmj::player::Config* pCfg, StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真の妥当性を検証する
|
||||
@param[in] eImgKind 対象画像タイプ
|
||||
@param[in] pImgData 対象画像データ
|
||||
@param[in] nImgDataSize 対象画像データサイズ
|
||||
@param[in] nFileSize 対象映像データのファイルサイズ
|
||||
@return 妥当ならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidatePicture(
|
||||
ImageKind eImgKind, const void* pImgData, std::size_t nImgDataSize, s64 nFileSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGの妥当性を検証する
|
||||
@param[in] pImgData 対象画像データ
|
||||
@param[in] nImgDataSize 対象画像データサイズ
|
||||
@param[in] nFileSize 対象映像データのファイルサイズ
|
||||
@return 妥当ならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidateJpeg(const void* pImgData, std::size_t nImgDataSize, s64 nFileSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPの妥当性を検証する
|
||||
@param[in] pImgData 対象画像データ
|
||||
@param[in] nImgDataSize 対象画像データサイズ
|
||||
@param[in] nFileSize 対象映像データのファイルサイズ
|
||||
@return 妥当ならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool ValidateMp(const void* pImgData, std::size_t nImgDataSize, s64 nFileSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief モーションJPEGの妥当性を検証する
|
||||
@param[in] pCfg 動画再生ライブラリ用コンフィグ(ヌル可)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 妥当ならtrue
|
||||
@details
|
||||
pCfgについてはExtractMovieFileInfo()の説明を参照してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
bool ValidateMotionJpeg(
|
||||
nmj::player::Config* pCfg,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
bool ValidateMotionJpeg(
|
||||
const nmj::player::FileInfo& rFileInfo,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検証結果を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValid() const { return m_bValid; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検証した映像の撮影日時を取得する
|
||||
@details
|
||||
検証に成功していない場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
DateTimeSeconds GetShotSeconds() const { NN_ASSERT(IsValid()); return m_ShotSeconds; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検証した映像のファイルサイズを取得する
|
||||
@details
|
||||
検証に成功していない場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
s64 GetFileSize() const { NN_ASSERT(IsValid()); return m_nFileSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検証した映像にサムネイルがあったかチェックする
|
||||
@details
|
||||
検証に成功していない場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool HasThumbnail() const { NN_ASSERT(IsValid()); return m_bHasThumbnail; }
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief モーションJPEGの妥当性を簡易検証する
|
||||
@param[in] rFileInfo 対象動画情報
|
||||
@return 妥当ならtrue
|
||||
@details
|
||||
ValidateMotionJpegはJPEGのヘッダ部までチェックするが、この関数はrFileInfo
|
||||
で分かる範囲までしかチェックしません。
|
||||
-----------------------------------------------------------------------*/
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
static bool ValidateMotionJpegSimple(const nmj::player::FileInfo& rFileInfo);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
|
||||
private:
|
||||
bool m_bValid;
|
||||
|
||||
DateTimeSeconds m_ShotSeconds;
|
||||
s64 m_nFileSize;
|
||||
bool m_bHasThumbnail;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_IMAGE_VALIDATOR_H_
|
||||
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbIndexInfo.h
|
||||
|
||||
映像データのインデックス情報
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_INDEX_INFO_H_
|
||||
#define IMAGE_DB_INDEX_INFO_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief インデクス情報構造体(POD)
|
||||
@details
|
||||
TWLのTCLIndexInfo構造体に準拠
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct IndexInfo
|
||||
{
|
||||
u16 nDirectoryIndex; //!< ディレクトリ番号 0~899
|
||||
u16 nFileIndex; //!< ファイル番号 0~9998
|
||||
|
||||
// ディレクトリ番号の最大値(DCF準拠)
|
||||
static const int c_nDirectoryIndexMax = 899;
|
||||
// ファイル番号の最大値(オフィシャル)
|
||||
static const int c_nOfficialFileIndexMax = 99;
|
||||
// ファイル番号の最大値(アンオフィシャル or DCF準拠)
|
||||
static const int c_nUnofficialFileIndexMax = 9998;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ番号を取得する
|
||||
@return ディレクトリ番号 通常:[0,899] ByDcf:[100,999]
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetDirectoryIndex() const { return nDirectoryIndex; }
|
||||
int GetDirectoryIndexByDcf() const { return ConvDirectoryIndexToDcf(GetDirectoryIndex()); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ番号を設定する
|
||||
@param[in] nIndex ディレクトリ番号 通常:[0,899] ByDcf:[100,999]
|
||||
@return 無効な入力の場合はfalse
|
||||
@details
|
||||
nIndexに範囲外の値を入力した場合は何も行わずにfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool SetDirectoryIndex(int nIndex);
|
||||
bool SetDirectoryIndexByDcf(int nIndex){ return SetDirectoryIndex(ConvDirectoryIndexFromDcf(nIndex)); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ番号が有効かチェックする
|
||||
@param[in] nIndex チェックするディレクトリ番号
|
||||
@return nIndexが[0,899]の範囲であればtrue、範囲外であればfalse
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
static bool IsValidDirectoryIndex(int nIndex);
|
||||
bool IsValidDirectoryIndex() const;
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ番号をDCF形式の番号へ変換する
|
||||
@param[in] nIndex ディレクトリ番号[0,899]
|
||||
@return DCF形式のディレクトリ番号[100,999]
|
||||
-----------------------------------------------------------------------*/
|
||||
static int ConvDirectoryIndexToDcf(int nIndex){ return nIndex + 100; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief DCF形式のディレクトリ番号を通常の番号へ変換する
|
||||
@param[in] nIndex DCF形式のディレクトリ番号[100,999]
|
||||
@return 通常のディレクトリ番号[0,899]
|
||||
-----------------------------------------------------------------------*/
|
||||
static int ConvDirectoryIndexFromDcf(int nIndexByDcf){ return nIndexByDcf - 100; }
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル番号を取得する
|
||||
@return ファイル番号 通常:[0,99] ByDcf:[1,9999]
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetFileIndex() const { return nFileIndex; }
|
||||
int GetFileIndexByDcf() const { return ConvFileIndexToDcf(GetFileIndex()); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル番号を設定する
|
||||
@param[in] nNo ファイル番号 通常:[0,9998] ByDcf:[1,9999]
|
||||
@return 無効な入力の場合はfalse
|
||||
@details
|
||||
noに範囲外の値を入力した場合は何も行わずにfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool SetFileIndex(int nIndex);
|
||||
bool SetFileIndexByDcf(int nIndex){ return SetFileIndex(ConvFileIndexFromDcf(nIndex)); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル番号が有効かチェックする
|
||||
@param[in] nIndex チェックするディレクトリ番号
|
||||
@return nIndexが[0,9998]の範囲であればtrue、範囲外であればfalse
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
static bool IsValidFileIndex(int nIndex);
|
||||
bool IsValidFileIndex() const;
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル番号をDCF形式の番号へ変換する
|
||||
@param[in] nIndex ファイル番号[0,99]
|
||||
@return DCF形式のディレクトリ番号[1,100]
|
||||
-----------------------------------------------------------------------*/
|
||||
static int ConvFileIndexToDcf(int nIndex){ return nIndex + 1; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief DCF形式のファイル番号を通常の番号へ変換する
|
||||
@param[in] nIndex DCF形式のファイル番号[1,100]
|
||||
@return 通常のディレクトリ番号[0,99]
|
||||
-----------------------------------------------------------------------*/
|
||||
static int ConvFileIndexFromDcf(int nIndexByDcf){ return nIndexByDcf - 1; }
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インデックスをオフィシャル形式で1つ進める
|
||||
@details
|
||||
ファイル番号は[1,100]までの範囲で進めていきます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void UpdateNextIndexByOfficial();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ディレクトリ単位でインデックスをオフィシャル形式で1つ進める
|
||||
@details
|
||||
ファイル番号は1になります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void UpdateNextDirectoryIndexByOfficial();
|
||||
|
||||
// 比較オペレータ
|
||||
bool operator==(const IndexInfo& rX) const;
|
||||
bool operator!=(const IndexInfo& rX) const;
|
||||
bool operator<(const IndexInfo& rX) const;
|
||||
bool operator<=(const IndexInfo& rX) const;
|
||||
bool operator>(const IndexInfo& rX) const;
|
||||
bool operator>=(const IndexInfo& rX) const;
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_INDEX_INFO_H_
|
||||
@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbInit.h
|
||||
|
||||
映像データベース初期化
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_INIT_H_
|
||||
#define IMAGE_DB_INIT_H_
|
||||
|
||||
#include <nn/fnd.h>
|
||||
#include "ImageDbResult.h"
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースの初期化を行う
|
||||
@param[in] rAllocator ライブラリが使用するアロケータ
|
||||
@details
|
||||
映像データベースを使用する前に一度だけ呼び出す必要があります。<BR>
|
||||
本関数を呼び出すと Finalize() が呼ばれるまで 575KB 程のメモリ消費されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void Initialize(nn::fnd::IAllocator& rAllocator);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースを終了させる
|
||||
*---------------------------------------------------------------------------*/
|
||||
void Finalize();
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_INIT_H_
|
||||
146
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbInitEx.h
Normal file
146
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbInitEx.h
Normal file
@ -0,0 +1,146 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbInitEx.h
|
||||
|
||||
映像データベース初期化
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_INIT_EX_H_
|
||||
#define IMAGE_DB_INIT_EX_H_
|
||||
|
||||
#include <nn/fnd.h>
|
||||
#include "ImageDbResult.h"
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースの初期化を行う
|
||||
@param[in] rAllocator ライブラリが使用するアロケータ
|
||||
@param[in] rFileAllocator ライブラリが使用する画像ファイル用アロケータ
|
||||
@param[in] bInitDbNand NAND側データベースを使用するフラグ
|
||||
@param[in] bInitDbSd SD側データベースを使用するフラグ
|
||||
@param[in] nLimitFileSize 読み込めるファイルサイズ(バイト単位)
|
||||
@param[out] rResultNand NAND側の初期化結果
|
||||
@param[out] rResultSd SD側の初期化結果
|
||||
@return すべて問題なければtrue
|
||||
@details
|
||||
映像データベースを使用する前に一度だけ呼び出す必要があります。
|
||||
戻り値がfalseの場合はrResultNandとrResultSdのいずれか、または両方にエラー
|
||||
が格納されていることになります。
|
||||
nLimitFileSizeを省略した場合はConst::c_nDefaultMaxReadImageFileSizeとして
|
||||
扱われます。
|
||||
通常はnLimitFileSizeの指定は行わない関数を使用してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool InitializeEx(
|
||||
nn::fnd::IAllocator& rAllocator,
|
||||
bool bInitDbNand, bool bInitDbSd,
|
||||
Result& rResultNand, Result& rResultSd);
|
||||
bool InitializeEx(
|
||||
nn::fnd::IAllocator& rAllocator, nn::fnd::IAllocator& rFileAllocator,
|
||||
bool bInitDbNand, bool bInitDbSd,
|
||||
std::size_t nLimitFileSize,
|
||||
Result& rResultNand, Result& rResultSd);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースを終了させる
|
||||
*---------------------------------------------------------------------------*/
|
||||
void FinalizeEx();
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースの復元処理を行う
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result Restore();
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief TWL-NANDの準備を行う
|
||||
@return 結果
|
||||
@details
|
||||
この関数を呼び出すとTWL-NANDにDSiウェアのための写真の管理ファイルを作成します。
|
||||
通常はInitializeEx()でNANDの写真を扱うように初期化すれば、TWL-NANDに管理ファ
|
||||
イルは作成されますが、ImageDbは使うつもりがなければ、この関数を使うほうが
|
||||
メモリや手間が省けます。
|
||||
既に管理ファイルが存在している場合は何も行いません。
|
||||
この関数はInitialize()やInitializeEx()で、ImageDbが初期化されていなくても
|
||||
呼び出せます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result SetupTwlNand(nn::fnd::IAllocator& rAllocator);
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースのシステムの初期化を行う
|
||||
@param[in] rAllocator ライブラリが使用するアロケータ
|
||||
@param[in] rFileAllocator ライブラリが使用する画像ファイル用アロケータ
|
||||
@param[in] bInitDbNand NAND側データベースを使用するフラグ
|
||||
@param[in] bInitDbSd SD側データベースを使用するフラグ
|
||||
@param[in] nLimitFileSize 読み込めるファイルサイズ(バイト単位)
|
||||
@return すべて問題なければtrue
|
||||
@details
|
||||
映像データベースを使用する前に最初に一度だけ呼び出す必要があります。
|
||||
この関数呼び出し後、InitializeBody()を呼び出すことでImageDbの初期化が完了し
|
||||
ます。
|
||||
この関数は特に必要がなければ使用しないでください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void InitializeSystem(
|
||||
nn::fnd::IAllocator& rAllocator, nn::fnd::IAllocator& rFileAllocator,
|
||||
bool bInitDbNand, bool bInitDbSd, std::size_t nLimitFileSize);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースのシステムを終了させる
|
||||
@details
|
||||
この関数は特に必要がなければ使用しないでください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void FinalizeSystem();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースの本体の初期化を行う
|
||||
@param[in] bInitDbNand NAND側データベースを使用するフラグ
|
||||
@param[in] bInitDbSd SD側データベースを使用するフラグ
|
||||
@param[out] rResultNand NAND側の初期化結果
|
||||
@param[out] rResultSd SD側の初期化結果
|
||||
@return すべて問題なければtrue
|
||||
@details
|
||||
映像データベースを使用する前に最初に一度だけ、InitializeSystem()呼び出し後に
|
||||
呼び出す必要があります。
|
||||
@details
|
||||
この関数は特に必要がなければ使用しないでください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool InitializeBody(
|
||||
bool bInitDbNand, bool bInitDbSd, Result& rResultNand, Result& rResultSd);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースの本体を終了させる
|
||||
@details
|
||||
この関数は特に必要がなければ使用しないでください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void FinalizeBody();
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief CTR-NANDの空き容量非制限フラグを取得する
|
||||
@retval true 空きが制限されていない状態
|
||||
@retval false 空きが制限されている状態
|
||||
@details
|
||||
ロンチ時のImageDb(3DSカメラ)は制限された状態で、NANDの写真撮影枚数が300と
|
||||
なります。
|
||||
制限なしの状態ではNANDの写真撮絵枚数は380となります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool GetUnlimitedCtrNandFreeSpaceFlag();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief CTR-NANDの空き容量非制限フラグを設定する
|
||||
@param[in] bUnlimited 非制限フラグ
|
||||
@details
|
||||
この関数はImageDbの初期化前に呼び出してください。
|
||||
初期化後に呼び出すとアサートが発生します。
|
||||
観設定の場合はデフォルトでfalse(制限状態)になっています。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void SetUnlimitedCtrNandFreeSpaceFlag(bool bUnlimited);
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_INIT_EX_H_
|
||||
@ -0,0 +1,347 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbLegacyTable.h
|
||||
|
||||
レガシー写真管理データ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_LEGACY_TABLE_H_
|
||||
#define IMAGE_DB_LEGACY_TABLE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbIndexInfo.h"
|
||||
#include "ImageDbDateTimeSeconds.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief レガシー写真管理データのヘッダ構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct LegacyTableHeader
|
||||
{
|
||||
public:
|
||||
u32 nSignature;
|
||||
u32 nVersion;
|
||||
u16 nNumElements;
|
||||
u8 nTargetArchive;
|
||||
u8 reserved0;
|
||||
IndexInfo sPicIdxInfo;
|
||||
IndexInfo sFrmIdxInfo;
|
||||
u16 nCrc;
|
||||
u16 nOffset;
|
||||
|
||||
// 識別子の内容
|
||||
static const u32 c_nSignature = 0x50495430; // 'OTIP'
|
||||
// バージョンの内容
|
||||
static const u32 c_nVersion = 0x315f3030; // '00_1'
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] nExtAreaSize 拡張領域サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(int nRecordNum, u16 nExtAreaSize=0);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコード数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ return nNumElements; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ターゲットアーカイブを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
StorageType GetTargetArchive() const;
|
||||
void SetTargetArchive(StorageType eStoType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真インデックス情報を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const IndexInfo& GetPictureIndexInfo() const { return sPicIdxInfo; }
|
||||
void SetPictureIndexInfo(const IndexInfo& rIdxInfo){ sPicIdxInfo = rIdxInfo; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief フレームインデックス情報を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const IndexInfo& GetFrameIndexInfo() const { return sFrmIdxInfo; }
|
||||
void SetFrameIndexInfo(const IndexInfo& rIdxInfo){ sFrmIdxInfo = rIdxInfo; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CRC値を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u16 GetCrc() const { return nCrc; }
|
||||
void SetCrc(u16 nCrc){ this->nCrc = nCrc; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 拡張領域の先頭アドレスを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetExtArea() const{
|
||||
return &reinterpret_cast<const u8*>(this)[sizeof(*this)]; }
|
||||
void* GetExtArea(){
|
||||
return const_cast<void*>(static_cast<const LegacyTableHeader&>(*this).GetExtArea()); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 拡張領域のサイズを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetExtAreaSize() const{ NN_ASSERT(sizeof(*this) <= nOffset); return (nOffset - sizeof(*this)); }
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief レガシー写真管理データのレコード構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
#pragma pack(push, 4)
|
||||
struct LegacyTableRecord
|
||||
{
|
||||
public:
|
||||
DateTimeSeconds sSeconds;
|
||||
int nFavoriteOrder;
|
||||
union {
|
||||
u32 nBitField;
|
||||
struct {
|
||||
u32 nValidity : 1;
|
||||
u32 nDirIdx : 10;
|
||||
u32 nFileIdx : 7;
|
||||
u32 nFavoriteType : 2;
|
||||
u32 nImageType : 2;
|
||||
u32 nkeyType : 2;
|
||||
u32 nDefaultFrame : 1;
|
||||
u32 nReserved : 7;
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
名前、値の範囲などをチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 有効フラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetValidityFlag() const { return (0 != nValidity); }
|
||||
void SetValidityFlag(bool bValidity){ nValidity = bValidity ? 1 : 0; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インデックス情報を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
IndexInfo GetIndexInfo() const;
|
||||
void SetIndexInfo(const IndexInfo& rIdxInfo);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影日時を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetSeconds() const{ return sSeconds; }
|
||||
void SetSeconds(const DateTimeSeconds& rDTSec){ sSeconds = rDTSec; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief お気に入りオーダーを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetFavoriteOrder() const{ return nFavoriteOrder; }
|
||||
void SetFavoriteOrder(int nOrder){ nFavoriteOrder = nOrder; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 署名の鍵タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyKeyType GetKeyType() const{ return static_cast<LegacyKeyType>(nkeyType); }
|
||||
void SetKeyType(LegacyKeyType eKey){ nkeyType = static_cast<u32>(eKey); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief お気に入りタイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyFavoriteType GetFavoriteType() const{ return static_cast<LegacyFavoriteType>(nFavoriteType); }
|
||||
void SetFavoriteType(LegacyFavoriteType eFavorite){ nFavoriteType = static_cast<u32>(eFavorite); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 画像タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyImageType GetImageType() const{ return static_cast<LegacyImageType>(nImageType); }
|
||||
void SetImageType(LegacyImageType eType){ nImageType = static_cast<u32>(eType); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デフォルトフレーム状態かチェック/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsDefaultFrame() const{ return static_cast<bool>(nDefaultFrame); }
|
||||
void SetDefaultFrame(bool bDefault){ nDefaultFrame = bDefault ? 1 : 0;}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief レガシー写真管理データ
|
||||
@details
|
||||
このクラスはレガシー写真管理データの実体を外部から受け取って動作するアクセサです。
|
||||
新規で管理データを用意する場合は ComputeTableSize() 分の確保したメモリを
|
||||
SetInitialTableData() で設定します。
|
||||
ファイルから読み込んだりした既存のデータを使用する場合は、SetExistingTableData()
|
||||
で設定します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class LegacyTable
|
||||
{
|
||||
public:
|
||||
//! 最大拡張領域サイズ(バイト単位)
|
||||
static const u16 c_nMaxExtAreaSize = 0xffff;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
LegacyTable();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータサイズ求める
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] nExtAreaSize 拡張領域のサイズ(バイト単位)
|
||||
@return サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static std::size_t ComputeTableSize(int nRecordNum, u16 nExtAreaSize=0);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータを取得する
|
||||
@return データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetTableData() const{ return m_pData; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータサイズを取得する
|
||||
@return サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetTableDataSize() const{ return m_nDataSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルデータを初期化して設定する
|
||||
@details
|
||||
指定のレコード数、拡張領域サイズがデータサイズを超えている場合はfalse
|
||||
を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetInitialTableData(void* pData, std::size_t nDataSize, int nRecordNum, u16 nExtAreaSize=0);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 既存の管理テーブルデータを設定する
|
||||
@details
|
||||
設定されたデータのヘッダ部を調査し、無効な場合はfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetExistingTableData(void* pData, std::size_t nDataSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
サイズ、識別子、CRCなどをチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのヘッダ部を取得する
|
||||
@return ヘッダ部
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const LegacyTableHeader* GetHeader() const{
|
||||
NN_NULL_ASSERT(m_pData);
|
||||
return reinterpret_cast<const LegacyTableHeader*>(m_pData); }
|
||||
|
||||
LegacyTableHeader* GetHeader(){
|
||||
return const_cast<LegacyTableHeader*>(static_cast<const LegacyTable&>(*this).GetHeader()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのヘッダ部に埋め込まれるCRCを更新する
|
||||
@details
|
||||
現在の内容からCRCを求めます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void UpdateCrc();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのレコード数を取得する
|
||||
@return レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ return GetHeader()->GetRecordNum(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのレコードを取得する
|
||||
@param[in] nIndex 取得するレコードのインデックス [0, GetRecordNum())
|
||||
@return レコード
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const LegacyTableRecord* GetRecord(int nIndex) const{
|
||||
NN_ASSERT(0 <= nIndex && nIndex < GetRecordNum());
|
||||
return &GetTopRecord()[nIndex]; }
|
||||
|
||||
LegacyTableRecord* GetRecord(int nIndex){
|
||||
return const_cast<LegacyTableRecord*>(static_cast<const LegacyTable&>(*this).GetRecord(nIndex)); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 使用済みレコード数を数える
|
||||
@return 使用済み管理レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int CountUsedRecordNum() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 未使用レコード数を取得する
|
||||
@return 未使用管理レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int CountEmptyRecordNum() const;
|
||||
|
||||
private:
|
||||
u16 ComputeCrc() const;
|
||||
|
||||
const LegacyTableRecord* GetTopRecord() const {
|
||||
return reinterpret_cast<const LegacyTableRecord*>(
|
||||
&reinterpret_cast<const u8*>(m_pData)[GetHeader()->nOffset]); }
|
||||
private:
|
||||
void* m_pData;
|
||||
std::size_t m_nDataSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_LEGACY_TABLE_H_
|
||||
@ -0,0 +1,211 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbMiscUtility.h
|
||||
|
||||
その他のユーティリティ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_MISC_UTILITY_H_
|
||||
#define IMAGE_DB_MISC_UTILITY_H_
|
||||
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
#include "ImageDbRecordParam.h"
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 配列の要素数を返す
|
||||
@param[in] x 配列
|
||||
@return 要素数
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define IMGDB_ARRAY_LEN_OF(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 安定なソート
|
||||
@param[in] first 開始イテレータ
|
||||
@param[in] end 終了イテレータ
|
||||
@param[in] pred プレディケート
|
||||
*---------------------------------------------------------------------------*/
|
||||
template<typename It, typename Func>
|
||||
void StableSort(It first, It end, Func pred)
|
||||
{
|
||||
// バブルソートアルゴリズム
|
||||
It itBottom = end;
|
||||
while(first != itBottom){
|
||||
It itLast = first;
|
||||
|
||||
for( It it = first+1; it != itBottom; ++it){
|
||||
// 大小比較は「より小さい(<)」で判定する
|
||||
// 「より小さい」だけで同じを判断するには「!(A < B) && !(B < A) 」で行う
|
||||
// A<B
|
||||
if(pred(*(it-1), *it)){
|
||||
// nop
|
||||
}
|
||||
// A>=B
|
||||
else{
|
||||
// B<A
|
||||
if(pred(*it, *(it-1))){
|
||||
std::swap(*(it-1), *it);
|
||||
itLast = it + 1;
|
||||
}
|
||||
// A>=B && B>=A = A==B
|
||||
else{
|
||||
// nop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itBottom = itLast;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ストレージの空き容量を取得する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 空きサイズ(バイト単位)
|
||||
@details
|
||||
何らかの理由で空きが取得できなかった場合はゼロを返します。
|
||||
対象ストレージがNANDの場合、bTwlCompatible=trueでTWL-NAND、falseでCTR-NANDの
|
||||
空きサイズを返します。
|
||||
SDの場合は無視されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
s64 GetStorageFreeSize(StorageType eStoType, bool bTwlCompatible);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真の残り撮影枚数を見積もる
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] nSize 写真1枚当たりの平均サイズ(バイト単位)
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 写真の残り撮影枚数
|
||||
@details
|
||||
空き容量と写真1枚の平均サイズから残り撮影枚数を見積もります。
|
||||
内部でGetStorageFreeSize()で取得したサイズで見積もります。
|
||||
対象ストレージがNANDの場合、bTwlCompatible=trueでTWL-NAND、falseでCTR-NANDの
|
||||
残り撮影枚数を返します。SDの場合は無視されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int EstimateRemainPictureNum(StorageType eStoType, std::size_t nSize, bool bTwlCompatible);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 空き容量を指定して写真の残り撮影枚数を見積もる
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] nFreeSize 対象ストレージの空き容量(Byte単位)
|
||||
@param[in] nSize 写真1枚当たりの平均サイズ(バイト単位)
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 写真の残り撮影枚数
|
||||
@details
|
||||
空き容量と写真1枚の平均サイズから残り撮影枚数を見積もります。
|
||||
対象ストレージがNANDの場合、bTwlCompatible=trueでTWL-NAND、falseでCTR-NANDの
|
||||
残り撮影枚数を返します。SDの場合は無視されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int EstimateRemainPictureNumWithFreeSize(StorageType eStoType, s64 nFreeSize, std::size_t nSize, bool bTwlCompatible);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真の残り撮影枚数を標準平均サイズで見積もる
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@return 写真の残り撮影枚数
|
||||
@details
|
||||
空き容量と写真1枚の標準的な平均サイズから残り撮影枚数を見積もります。
|
||||
内部でGetStorageFreeSize()で取得した空き容量で見積もります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int EstimateRemainPictureNumByDefault(StorageType eStoType);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief NAND側の空き容量を指定して写真の残り撮影枚数を標準平均サイズで見積もる
|
||||
@param[in] nFreeSizeCtr CTR-NAND側の空きサイズ
|
||||
@param[in] nFreeSizeTwl TWL-NAND側の空きサイズ
|
||||
@return 写真の残り撮影枚数
|
||||
@details
|
||||
指定空き容量と写真1枚の標準的な平均サイズから残り撮影枚数を見積もります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int EstimateRemainPictureNumByDefaultWithFreeSizeInNand(s64 nFreeSizeCtr, s64 nFreeSizeTwl);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief NAND側の空き容量を指定して写真の残り撮影枚数を標準平均サイズで見積もる
|
||||
@param[in] nFreeSize SDの空きサイズ
|
||||
@return 写真の残り撮影枚数
|
||||
@details
|
||||
指定空き容量と写真1枚の標準的な平均サイズから残り撮影枚数を見積もります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int EstimateRemainPictureNumByDefaultWithFreeSizeInSd(s64 nFreeSize);
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 動画の最悪時の1秒あたりのサイズを見積もる
|
||||
@return 最悪時の1秒あたりのサイズ(バイト)
|
||||
@details
|
||||
固定値を返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
std::size_t EstimateMovieWorstSizePerSec();
|
||||
#endif // IMGDB_ENABLE_MOVIE
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 動画の録画可能時間を見積もる
|
||||
@return 録画可能時間(秒単位)
|
||||
@details
|
||||
SDカードの空き容量と管理ファイルの空きを参照して求めます。
|
||||
SDカードが刺さっていない場合はゼロを返します。
|
||||
ここで返される時間は動画のデータサイズが最大になった時のことで見積もられて
|
||||
いるため、最低でもこの時間は撮影できることが保証されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
f32 EstimateMovieRecordingTime();
|
||||
#endif // IMGDB_ENABLE_MOVIE
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
自分の本体IDを取得する
|
||||
@return 本体ID
|
||||
*---------------------------------------------------------------------------*/
|
||||
u32 GetOwnBodyId();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像情報から別の映像情報を生成する
|
||||
@param[out] rImgInfoNew 生成した映像情報
|
||||
@param[in] rImgInfoBase 生成元の映像情報
|
||||
@param[in] eImgKind 生成後の映像データの種類
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@details
|
||||
bTwlCompatible=falseの場合、rImgInfoMpの拡張子をJPEGに変えたものを作成します。
|
||||
trueの場合は拡張子に加え、フォルダ名を ???NIN02 にしたものを作成します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
void GenerateImageInfoFromImageInfo(
|
||||
ImageInfo& rImgInfoNew, const ImageInfo& rImgInfoBase, bool bTwlCompatible);
|
||||
void GenerateImageInfoFromImageInfo(
|
||||
ImageInfo& rImgInfoNew, const ImageInfo& rImgInfoBase, ImageKind eImgKind, bool bTwlCompatible);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイルのフルパスから映像情報を生成する
|
||||
@param[out] rImgInfo 生成した映像情報
|
||||
@param[out] rStoType 生成した映像データの種類
|
||||
@param[in] pPath 生成元のファイルパス
|
||||
@return 生成に成功した場合はtrue
|
||||
@details
|
||||
pPathはドライブ名まで含まれたフルパスを指定する必要があります。
|
||||
不正なパスを指定した場合はfalseを返します。その際のrImgInfo、rStoTypeの内容は
|
||||
不定です。
|
||||
rImgInfoにはディレクトリ名、ファイル名、拡張子のデータが格納されます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool GenerateImageInfoFromFullPath(
|
||||
ImageInfo& rImgInfo, StorageType& rStoType, const wchar_t* pPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ImageInfo←→ImageDbRecordParamの代入処理
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
void StoreImageDbRecordParam2ImageInfo(ImageInfo& rImgInfo, const ImageDbRecordParam& rImgRecParam);
|
||||
void StoreImageInfo2ImageDbRecordParam(ImageDbRecordParam& rImgRecParam, const ImageInfo& rImgInfo);
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_MISC_UTILITY_H_
|
||||
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbNmjPlayerConfig.h
|
||||
|
||||
NMJプレイヤーのコンフィグデータ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_NMJ_PLAYER_CONFIG_H_
|
||||
#define IMAGE_DB_NMJ_PLAYER_CONFIG_H_
|
||||
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
#include "../../Movie/nmjPlayer.h"
|
||||
#endif // IMAGE_DB_IMAGE_UTILITY_H_
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief nmj::player::Config定義クラス
|
||||
@details
|
||||
動画再生ライブラリをスレッドなどで非同期で動かす場合(例えば動画ファイル情報
|
||||
を取得するなど)、nmj::player::Configもそれぞれ独自に用意する必要があります。
|
||||
(正確にはConfigで指定したファイル操作関連の関数が利用するファイルハンドラが、
|
||||
独立している必要がある)
|
||||
|
||||
このクラスを利用する場合、テンプレート引数idに他と被らない正の値を指定します。
|
||||
例:
|
||||
NmjPlayerConfig<1> configA;
|
||||
NmjPlayerConfig<2> configB;
|
||||
こうすることでconfigAとBは、それぞれ別のファイルハンドラを持ったデータとな
|
||||
り、AとB間では独立して操作することができるようになります。
|
||||
|
||||
GetConfig()で取得できるConfigは、ファイル操作に関係するメンバはセットされて
|
||||
いますが、それ以外はゼロが格納されています。
|
||||
nmj::player::Player::GetFileInfoSync()で利用する限りは、デフォルトのままで
|
||||
問題ありませんが、他で利用する場合は各種パラメータを設定する必要があります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template<int id>
|
||||
class NmjPlayerConfig
|
||||
{
|
||||
enum { Id = id };
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
NmjPlayerConfig(){
|
||||
std::memset(&m_Config, 0, sizeof(m_Config));
|
||||
// fileFunc.
|
||||
m_Config.fileFunc.pInitialize = OpenRead;
|
||||
m_Config.fileFunc.pRead = Read;
|
||||
m_Config.fileFunc.pGetSize = GetSize;
|
||||
m_Config.fileFunc.pSeek = Seek;
|
||||
m_Config.fileFunc.pFinalize = Close;
|
||||
|
||||
// Img.
|
||||
m_Config.img.width = nmj::player::NUM_MOVIE_WIDTH_MAX;
|
||||
m_Config.img.height = nmj::player::NUM_MOVIE_HEIGHT_MAX;
|
||||
|
||||
m_bOpend = false;
|
||||
}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~NmjPlayerConfig(){ Close(m_Config.fileFunc.arg); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンフィグデータを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const nmj::player::Config& GetConfig() const{ return m_Config; }
|
||||
nmj::player::Config& GetConfig(){ return const_cast<nmj::player::Config&>(static_cast<const NmjPlayerConfig<id>&>(*this).GetConfig()); }
|
||||
//@}
|
||||
|
||||
private:
|
||||
// 読み込みモードでオープンする
|
||||
static bool OpenRead(void* pArg, const wchar_t* pPath){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(!m_bOpend);
|
||||
const nn::Result ret = m_FileStream.TryInitialize(pPath, nn::fs::OPEN_MODE_READ);
|
||||
m_bOpend = ret.IsSuccess();
|
||||
return m_bOpend;
|
||||
}
|
||||
|
||||
// クローズする
|
||||
static bool Close(void* pArg){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
if(m_bOpend){
|
||||
m_bOpend = false;
|
||||
m_FileStream.Finalize();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 読み込む
|
||||
static bool Read(void* pArg, u8* pDst, std::size_t nSize){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(m_bOpend);
|
||||
s32 nReadSize;
|
||||
const nn::Result ret = m_FileStream.TryRead(&nReadSize, pDst, nSize);
|
||||
if(ret.IsSuccess() && static_cast<std::size_t>(nReadSize) == nSize){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
Close(pArg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ファイルサイズを取得する
|
||||
static bool GetSize(void* pArg, std::size_t* pSize){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(m_bOpend);
|
||||
NN_NULL_ASSERT(pSize);
|
||||
s64 nSize64;
|
||||
const nn::Result ret = m_FileStream.TryGetSize(&nSize64);
|
||||
std::size_t nSize32 = static_cast<std::size_t>(nSize64);
|
||||
if(ret.IsSuccess() && nSize32 == nSize64){
|
||||
*pSize = nSize32;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
Close(pArg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ファイル先頭からシークする
|
||||
static bool Seek(void* pArg, s64 nOfst){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(m_bOpend);
|
||||
const nn::Result ret = m_FileStream.TrySeek(nOfst, nn::fs::POSITION_BASE_BEGIN);
|
||||
if(ret.IsSuccess()){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
Close(pArg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static nmj::player::Config m_Config;
|
||||
static nn::fs::FileStream m_FileStream;
|
||||
static bool m_bOpend;
|
||||
};
|
||||
|
||||
template<int id> nmj::player::Config NmjPlayerConfig<id>::m_Config;
|
||||
template<int id> nn::fs::FileStream NmjPlayerConfig<id>::m_FileStream;
|
||||
template<int id> bool NmjPlayerConfig<id>::m_bOpend;
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_NMJ_PLAYER_CONFIG_H_
|
||||
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbNmjRecordingConfig.h
|
||||
|
||||
NMJレコーダーのレコーディングコンフィグデータ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_NMJ_RECORDING_CONFIG_H_
|
||||
#define IMAGE_DB_NMJ_RECORDING_CONFIG_H_
|
||||
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
#include "../../Movie/nmjRecorder.h"
|
||||
#endif // IMAGE_DB_IMAGE_UTILITY_H_
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief nmj::recorder::RecordingConfig定義クラス
|
||||
@details
|
||||
動画録画ライブラリをスレッドなどで非同期で動かす場合(例えば動画ファイル情報
|
||||
を取得するなど)、nmj::recorder::RecordingConfigもそれぞれ独自に用意する必要
|
||||
があります。
|
||||
(正確にはConfigで指定したファイル操作関連の関数が利用するファイルハンドラが、
|
||||
独立している必要がある)
|
||||
|
||||
このクラスを利用する場合、テンプレート引数idに他と被らない正の値を指定します。
|
||||
例:
|
||||
NmjRecordingConfig<1> configA;
|
||||
NmjRecordingConfig<2> configB;
|
||||
こうすることでconfigAとBは、それぞれ別のファイルハンドラを持ったデータとな
|
||||
り、AとB間では独立して操作することができるようになります。
|
||||
|
||||
GetConfig()で取得できるConfigは、ファイル操作に関係するメンバはセットされて
|
||||
いますが、それ以外はゼロが格納されています。
|
||||
*---------------------------------------------------------------------------*/
|
||||
template<int id>
|
||||
class NmjRecordingConfig
|
||||
{
|
||||
enum { Id = id };
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
NmjRecordingConfig(){
|
||||
std::memset(&m_Config, 0, sizeof(m_Config));
|
||||
|
||||
// fileFunc.
|
||||
m_Config.fileFunc.pInitialize = OpenWrite;
|
||||
m_Config.fileFunc.pWrite = Write;
|
||||
m_Config.fileFunc.pSetSize = SetSize;
|
||||
m_Config.fileFunc.pSeek = Seek;
|
||||
m_Config.fileFunc.pFinalize = Close;
|
||||
m_Config.fileFunc.pDeleteFile = Delete;
|
||||
|
||||
m_cPath[0] = '\0';
|
||||
m_bOpend = false;
|
||||
}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~NmjRecordingConfig(){ Close(m_Config.fileFunc.arg); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 操作するファイルのパスを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const wchar_t* GetPath() const{ return m_cPath; }
|
||||
void SetPath(const wchar_t* pPath){ NN_NULL_ASSERT(pPath); std::strcpy(m_cPath, pPath); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンフィグデータを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const nmj::recorder::RecordingConfig& GetConfig() const{ return m_Config; }
|
||||
nmj::recorder::RecordingConfig& GetConfig(){ return const_cast<nmj::recorder::RecordingConfig&>(static_cast<const NmjRecordingConfig<id>&>(*this).GetConfig()); }
|
||||
//@}
|
||||
|
||||
private:
|
||||
// 書き込みモードでオープンする
|
||||
static bool OpenWrite(void* pArg){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(!m_bOpend);
|
||||
const nn::Result ret = m_FileStream.TryInitialize(m_cPath, nn::fs::OPEN_MODE_WRITE | nn::fs::OPEN_MODE_CREATE);
|
||||
m_bOpend = ret.IsSuccess();
|
||||
return m_bOpend;
|
||||
}
|
||||
|
||||
// クローズする
|
||||
static bool Close(void* pArg){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
if(m_bOpend){
|
||||
m_bOpend = false;
|
||||
m_FileStream.Finalize();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 書き込む
|
||||
static bool Write(void* pArg, const u8* pSrc, std::size_t nSize){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(m_bOpend);
|
||||
s32 nWriteSize;
|
||||
const nn::Result ret = m_FileStream.TryWrite(&nWriteSize, pSrc, nSize);
|
||||
if(ret.IsSuccess() && static_cast<std::size_t>(nWriteSize) == nSize){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
Close(pArg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ファイルサイズを設定する
|
||||
static bool SetSize(void* pArg, std::size_t nSize){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(m_bOpend);
|
||||
const nn::Result ret = m_FileStream.TrySetSize(nSize);
|
||||
if(ret.IsSuccess()){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
Close(pArg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ファイル先頭からシークする
|
||||
static bool Seek(void* pArg, s64 nOfst){
|
||||
NN_UNUSED_VAR(pArg);
|
||||
NN_ASSERT(m_bOpend);
|
||||
const nn::Result ret = m_FileStream.TrySeek(nOfst, nn::fs::POSITION_BASE_BEGIN);
|
||||
if(ret.IsSuccess()){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
Close(pArg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ファイルを削除する
|
||||
static bool Delete(){
|
||||
NN_ASSERT(!m_bOpend);
|
||||
const nn::Result ret = nn::fs::TryDeleteFile(m_cPath);
|
||||
return ret.IsSuccess();
|
||||
}
|
||||
|
||||
private:
|
||||
static nmj::recorder::RecordingConfig m_Config;
|
||||
static nn::fs::FileStream m_FileStream;
|
||||
static wchar_t m_cPath[nn::fs::MAX_FILE_PATH_LENGTH+1];
|
||||
static bool m_bOpend;
|
||||
};
|
||||
|
||||
template<int id> nmj::recorder::RecordingConfig NmjRecordingConfig<id>::m_Config;
|
||||
template<int id> nn::fs::FileStream NmjRecordingConfig<id>::m_FileStream;
|
||||
template<int id> wchar_t NmjRecordingConfig<id>::m_cPath[nn::fs::MAX_FILE_PATH_LENGTH+1];
|
||||
template<int id> bool NmjRecordingConfig<id>::m_bOpend;
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_NMJ_RECORDING_CONFIG_H_
|
||||
@ -0,0 +1,372 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbPathUtility.h
|
||||
|
||||
文字列、パス関連ユーティリティ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_PATH_UTILITY_H_
|
||||
#define IMAGE_DB_PATH_UTILITY_H_
|
||||
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbIndexInfo.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 大文字を小文字にする
|
||||
@param[in] c 文字
|
||||
@return 変換された文字
|
||||
*---------------------------------------------------------------------------*/
|
||||
inline char ToLower(char c){ return ('A'<=c&&c<='Z') ? ('a'-'A'+c) : c; }
|
||||
inline wchar_t ToLower(wchar_t c){ return (L'A'<=c&&c<=L'Z') ? (L'a'-L'A'+c) : c; }
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 小文字を大文字にする
|
||||
@param[in] c 文字
|
||||
@return 変換された文字
|
||||
*---------------------------------------------------------------------------*/
|
||||
inline char ToUpper(char c){ return ('a'<=c&&c<='z') ? (c-('a'-'A')) : c; }
|
||||
inline wchar_t ToUpper(wchar_t c){ return (L'a'<=c&&c<=L'z') ? (c-(L'a'-L'A')) : c; }
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ワイド文字列を大文字/小文字区別なく比較する
|
||||
@param[in] pStr1 比較文字列
|
||||
@param[in] pStr2 比較文字列
|
||||
@return 一致した場合はゼロ
|
||||
*---------------------------------------------------------------------------*/
|
||||
int WStricmp(const wchar_t* pStr1, const wchar_t* pStr2);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ワイド文字列を文字数を指定して大文字/小文字区別なく比較する
|
||||
@param[in] pStr1 比較文字列
|
||||
@param[in] pStr2 比較文字列
|
||||
@param[in] nCount 比較文字数
|
||||
@return 一致した場合はゼロ
|
||||
*---------------------------------------------------------------------------*/
|
||||
int WStrnicmp(const wchar_t* pStr1, const wchar_t* pStr2, int nCount);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief DCFで使用可能な文字かチェックする
|
||||
@param[in] c 文字
|
||||
@return 使用可能であればtrue
|
||||
@details
|
||||
0-9、A-Z、a-z、_(アンダースコア)の文字が使用可能です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
inline bool IsDcfCharacter(char c){ return ('0'<=c&&c<='9' || 'A'<=c&&c<='Z' || 'a'<=c&&c<='z' || '_'==c); }
|
||||
inline bool IsDcfCharacter(wchar_t c){ return (L'0'<=c&&c<=L'9' || L'A'<=c&&c<=L'Z' || L'a'<=c&&c<=L'z' || L'_'==c); }
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 数字を数値に変換する
|
||||
@param[out] rN 数値
|
||||
@param[in] pStr 数字
|
||||
@param[in] nLength 変換文字数
|
||||
@return 変換に失敗した場合はfalse
|
||||
@details
|
||||
nLengthを指定した場合は指定した文字数に達するか、文字列終端になるまでの変換
|
||||
を行います。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool AToI(int& rN, const char* pStr);
|
||||
bool AToI(int& rN, const char* pStr, int nLength);
|
||||
bool AToI(int& rN, const wchar_t* pStr);
|
||||
bool AToI(int& rN, const wchar_t* pStr, int nLength);
|
||||
//@}
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 各ドライブ領域のドライブ名を取得する
|
||||
@return ドライブ名
|
||||
@details
|
||||
例:"sdmc:/"
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
const wchar_t* GetTwlNandDriveName();
|
||||
const wchar_t* GetCtrNandDriveName();
|
||||
const wchar_t* GetSdDriveName();
|
||||
//@}
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 各ドライブ領域のドライブ名の文字数を取得する
|
||||
@return 文字数
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetTwlNandDriveNameLength();
|
||||
int GetCtrNandDriveNameLength();
|
||||
int GetSdDriveNameLength();
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 各ドライブ領域のドライブ名をパスに付加する
|
||||
@param[io] pStr 付加する文字列
|
||||
@param[in] nSize pStrのバッファサイズ(文字数)
|
||||
@details
|
||||
Const::c_nMaxDriveNameLength分の空きがあれば、確実にドライブ名を付加できます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
void AppendTwlNandDriveName(wchar_t* pPath, int nSize);
|
||||
void AppendCtrNandDriveName(wchar_t* pPath, int nSize);
|
||||
void AppendSdDriveName(wchar_t* pPath, int nSize);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 有効なDCFディレクトリ名かチェックする
|
||||
@param[in] pDirName チェックするディレクトリ名
|
||||
@param[out] pDirNo ディレクトリ番号(ヌル可)
|
||||
@return 有効ならtrue
|
||||
@details
|
||||
"100NIN02"
|
||||
WithoutLength版は文字数が多すぎたとしても考慮しません(短すぎる場合はエラーとなる)。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ValidateDcfDirectoryName(const char* pDirName, int* pDirNo=0);
|
||||
bool ValidateDcfDirectoryName(const wchar_t* pDirName, int* pDirNo=0);
|
||||
bool ValidateDcfDirectoryNameWithoutLength(const char* pDirName, int* pDirNo=0);
|
||||
bool ValidateDcfDirectoryNameWithoutLength(const wchar_t* pDirName, int* pDirNo=0);
|
||||
//@}
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief DCFディレクトリ名からディレクトリ番号を取得する
|
||||
@param[in] pDirName 対象のディレクトリ名
|
||||
@return ディレクトリ番号[100,999]
|
||||
@details
|
||||
"100NIN02" -> 100
|
||||
このメソッドはDCFディレクトリ名の前半3文字の数字を数値に変換するだけです。
|
||||
前半3文字が数字でない場合はエラーとなりますが、後半5文字に関しては無視します。
|
||||
数字部分が無効な場合はマイナスを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetDirectoryNoFromDcfDirectoryName(const char* pDirName);
|
||||
int GetDirectoryNoFromDcfDirectoryName(const wchar_t* pDirName);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 有効なDCFファイル名かチェックする
|
||||
@param[in] pFileName チェックするファイル名
|
||||
@param[out] pDirNo ファイル番号(ヌル可)
|
||||
@return 有効ならtrue
|
||||
@details
|
||||
"HNI_0001.JPG" or "HNI_0001"
|
||||
拡張子は有っても無くても問題ありません
|
||||
WithoutLength版は文字数が多すぎたとしても考慮しません(短すぎる場合はエラーとなる)。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ValidateDcfFileName(const char* pFileName, int* pFileNo=0);
|
||||
bool ValidateDcfFileName(const wchar_t* pFileName, int* pFileNo=0);
|
||||
bool ValidateDcfFileNameWithoutLength(const char* pFileName, int* pFileNo=0);
|
||||
bool ValidateDcfFileNameWithoutLength(const wchar_t* pFileName, int* pFileNo=0);
|
||||
//@}
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief DCFファイル名からファイル番号を取得する
|
||||
@param[in] pFileName 対象のァイル名
|
||||
@return ファイル番号[1,9999]
|
||||
@details
|
||||
"HNI_0001.JPG" -> 1
|
||||
このメソッドはDCFファイル名の後半4文字の数字を数値に変換するだけです。
|
||||
後半4文字が数字でない、前半4文字に終端に終端記号が含まれている場合はエラー
|
||||
となりますが、それ以外のチェックは行いません。
|
||||
数字部分が無効な場合はマイナスを返します。
|
||||
拡張子は有っても無くても問題ありません
|
||||
*---------------------------------------------------------------------------*/
|
||||
int GetFileNoFromDcfFileName(const char* pFileName);
|
||||
int GetFileNoFromDcfFileName(const wchar_t* pFileName);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ファイルパスからディレクトリパスを生成する
|
||||
@param[out] pDirPath 生成したディレクトリパス
|
||||
@param[in] nSize pDirPathのバッファサイズ(文字数)
|
||||
@param[in] pFilePath ファイルパス
|
||||
@details
|
||||
"sdmc:/DCIM/100NIN02/HNI_0001.JPG" -> "sdmc:/DCIM/100NIN02"
|
||||
格納先のバッファが不足している場合はアサートが発生します。
|
||||
バッファはpFilePathの文字数+1以上のサイズであれば十分です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
void CreateDirectoryPathFromFilePath(wchar_t* pDirPath, int nSize, const wchar_t* pFilePath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像のファイル名を生成する
|
||||
@param[out] pStr 生成した文字列を格納するバッファ
|
||||
@param[in] nSize バッファサイズ(文字数)
|
||||
@param[in] rIdxInfo インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"HNI_0001"
|
||||
バッファは Const::c_nImageFileNameLength+1 以上のサイズが必要です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int CreateImageFileName(
|
||||
wchar_t* pStr, int nSize,
|
||||
const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
int CreateImageFileName(
|
||||
wchar_t* pStr, int nSize,
|
||||
const ImageInfo& rImgInfo);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像のファイル名を拡張子付きで生成する
|
||||
@param[out] pStr 生成した文字列を格納するバッファ
|
||||
@param[in] nSize バッファサイズ(文字数)
|
||||
@param[in] eImgKind 映像の種類
|
||||
@param[in] rIdxInfo インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"HNI_0001.JPG"
|
||||
バッファは Const::c_nMaxImageFilePathLength+1 以上のサイズが必要です。
|
||||
(拡張子によって文字数が変動するため少なくても動作するときはありますが非推奨)
|
||||
*---------------------------------------------------------------------------*/
|
||||
int CreateImageFileNameWithExt(
|
||||
wchar_t* pStr, int nSize,
|
||||
ImageKind eImgKind, const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
int CreateImageFileNameWithExt(
|
||||
wchar_t* pStr, int nSize,
|
||||
const ImageInfo& rImgInfo);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像のディレクトリ名を生成する
|
||||
@param[out] pStr 生成した文字列を格納するバッファ
|
||||
@param[in] nSize バッファサイズ(文字数)
|
||||
@param[in] rIdxInfo インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"100NIN02"
|
||||
バッファは Const::c_nImageDirectoryLength+1 以上のサイズが必要です。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int CreateImageDirectoryName(
|
||||
wchar_t* pStr, int nSize,
|
||||
const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
int CreateImageDirectoryName(
|
||||
wchar_t* pStr, int nSize,
|
||||
const ImageInfo& rImgInfo);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 指定映像のファイルパスを生成する
|
||||
@param[out] pStr 生成したパスを格納するバッファ
|
||||
@param[in] nSize バッファのサイズ(文字数単位)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"sdmc:/DCIM/100NIN02/HNI_0001.JPG"
|
||||
バッファは Const::c_nMaxImageFileFullPathLength+1 以上のサイズが必要です。
|
||||
(文字数は変動するため少なくても動作するときはありますが非推奨)
|
||||
引数にLegacyPictureInfoを渡すタイプの場合は拡張子は"JPG"となります。
|
||||
bTwlCompatibleはTWL互換用の領域を指定するフラグで、対象ストレージがNANDで、
|
||||
JPEGファイル時のみ意味があります(それ以外では無視されます)。falseを指定
|
||||
するとCTR領域、trueを指定するとTWL領域のパスを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
int CreateImagePath(
|
||||
wchar_t* pStr, int nSize,
|
||||
StorageType eStoType, ImageKind eImgKind, const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
int CreateImagePath(
|
||||
wchar_t* pStr, int nSize,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 指定映像のディレクトリパスを生成する
|
||||
@param[out] pStr 生成したパスを格納するバッファ
|
||||
@param[in] nSize バッファのサイズ(文字数単位)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] rImgInfo 対象映像情報
|
||||
@param[in] rIdxInfo 対象インデックス情報
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"sdmc:/DCIM/100NIN02"
|
||||
バッファは Const::c_nMaxImageDirectoryPathLength+1 以上のサイズが必要です。
|
||||
(文字数は変動するため少なくても動作するときはありますが非推奨)
|
||||
bTwlCompatibleはTWL互換用の領域を指定するフラグで、対象ストレージがNANDで、
|
||||
JPEGファイル時のみ意味があります(それ以外では無視されます)。falseを指定
|
||||
するとCTR領域、trueを指定するとTWL領域のパスを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
int CreateImageDirectoryPath(
|
||||
wchar_t* pStr, int nSize,
|
||||
StorageType eStoType, const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
int CreateImageDirectoryPath(
|
||||
wchar_t* pStr, int nSize,
|
||||
StorageType eStoType, const IndexInfo& rIdxInfo, bool bTwlCompatible);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像のルートディレクトリパスを生成する
|
||||
@param[out] pStr 生成したパスを格納するバッファ
|
||||
@param[in] nSize バッファのサイズ(文字数単位)
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
例:"sdmc:/DCIM"
|
||||
バッファは Const::c_nMaxRootDirectoryPathLength+1 以上のサイズが必要です。
|
||||
(文字数は変動するため少なくても動作するときはありますが非推奨)
|
||||
bTwlCompatibleはTWL互換用の領域を指定するフラグで、対象ストレージがNANDで、
|
||||
JPEGファイル時のみ意味があります(それ以外では無視されます)。falseを指定
|
||||
するとCTR領域、trueを指定するとTWL領域のパスを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int CreateImageRootDirectoryPath(
|
||||
wchar_t* pStr, int nSize, StorageType eStoType, bool bTwlCompatible);
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 各種写真管理ファイルのパスを取得する
|
||||
@return ファイルパス
|
||||
@details
|
||||
例:"sdmc:/private/ds/app/484E494A/pit.bin"
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
const wchar_t* GetLegacyPictureDbFilePath(StorageType eStoType);
|
||||
const wchar_t* GetPictureDbFilePath(StorageType eStoType);
|
||||
//@}
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 各種写真管理ファイルのディレクトリパスを取得する
|
||||
@return ディレクトリパス
|
||||
@details
|
||||
例:"sdmc:/private/ds/app/484E494A"
|
||||
*---------------------------------------------------------------------------*/
|
||||
//@{
|
||||
const wchar_t* GetLegacyPictureDbFileDir(StorageType eStoType);
|
||||
const wchar_t* GetPictureDbFileDir(StorageType eStoType);
|
||||
//@}
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 仮想パスかチェックする
|
||||
@param[in] チェックするパス
|
||||
@return 仮想パスならtrue
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsVirtualPath(const wchar_t* pPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 仮想パスを実パスに変換する
|
||||
@param[out] pRPath 変換後の実パス
|
||||
@param[in] nSize pRPathのバッファのサイズ(文字数単位)
|
||||
@param[in] pVPath 変換前の仮想パス
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
渡された仮想パスを実パスに変換してpRPathへ格納します。
|
||||
仮想パスでない(判断できない)場合はpVPathの内容をpRPathへそのまま格納します。
|
||||
nSizeは変換元で要求された以上のサイズが必要になります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int ConvertVirtualToRealPath(wchar_t* pRPath, int nSize, const wchar_t* pVPath);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 実パスを仮想パスに変換する
|
||||
@param[out] pVPath 変換後の仮想パス
|
||||
@param[in] nSize pVPathのバッファのサイズ(文字数単位)
|
||||
@param[in] pRPath 変換前の実パス
|
||||
@return 格納した文字数(終端文字は含まない)
|
||||
@details
|
||||
渡された実パスを仮想パスに変換してpVPathへ格納します。
|
||||
実パスでない(判断できない)場合はpRPathの内容をpVPathへそのまま格納します。
|
||||
nSizeは変換元で要求された以上のサイズが必要になります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int ConvertRealToVirtualPath(wchar_t* pVPath, int nSize, const wchar_t* pRPath);
|
||||
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_PATH_UTILITY_H_
|
||||
@ -0,0 +1,328 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbPictureDatabase.h
|
||||
|
||||
写真データベース
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_PICTURE_DATABASE_H_
|
||||
#define IMAGE_DB_PICTURE_DATABASE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbRecord.h"
|
||||
#include "ImageDbLegacyTable.h"
|
||||
#include "ImageDbPictureTable.h"
|
||||
#include "ImageDbValidityStateTable.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
class PictureDatabase;
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真データベースレコード
|
||||
@details
|
||||
コピー可能
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PictureDbRecord : public ImageDbRecord
|
||||
{
|
||||
friend class PictureDatabase;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
PictureDbRecord();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
virtual const ImageInfo& GetImageInfo() const;
|
||||
virtual ImageInfo& GetImageInfo(){
|
||||
return const_cast<ImageInfo&>(static_cast<const PictureDbRecord&>(*this).GetImageInfo()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像妥当性管理レコードを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
virtual const ValidityStateTableRecord& GetValidityStateTableRecord() const;
|
||||
virtual ValidityStateTableRecord& GetValidityStateTableRecord(){
|
||||
return const_cast<ValidityStateTableRecord&>(static_cast<const PictureDbRecord&>(*this).GetValidityStateTableRecord()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真管理レコードを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const PictureTableRecord& GetPictureTableRecord() const;
|
||||
PictureTableRecord& GetPictureTableRecord(){
|
||||
return const_cast<PictureTableRecord&>(static_cast<const PictureDbRecord&>(*this).GetPictureTableRecord()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レガシー写真管理レコードを取得する
|
||||
@details
|
||||
レガシー写真の管理自体を行わないことがあるため、その場合はヌルを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const LegacyTableRecord* GetLegacyTableRecord() const;
|
||||
LegacyTableRecord* GetLegacyTableRecord(){
|
||||
return const_cast<LegacyTableRecord*>(static_cast<const PictureDbRecord&>(*this).GetLegacyTableRecord()); }
|
||||
//@}
|
||||
|
||||
private:
|
||||
bool IsInitialized() const;
|
||||
void Initialize(PictureDatabase& rDb, int nIndex);
|
||||
|
||||
private:
|
||||
PictureDatabase* m_pDb;
|
||||
int m_nIndex;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真データベース
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PictureDatabase : private nn::util::NonCopyable<PictureDatabase>
|
||||
{
|
||||
friend class PictureDbRecord;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rAllocator 使用するメモリアロケータ
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] eStoType 対象としているストレージ
|
||||
@details
|
||||
nRecordNumは初期化時に作られる管理テーブルのレコード数の決定と、ファイル
|
||||
読み込み時のレコード数に関係します。
|
||||
引数を渡さない呼出をした場合は別途Initialize()で初期化を行ってください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
PictureDatabase();
|
||||
PictureDatabase(Allocator& rAllocator, int nRecordNum, StorageType eStoType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
~PictureDatabase();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化済みかチェックする
|
||||
@return 初期化済みならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsInitialized() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@param[in] rAllocator 使用するメモリアロケータ
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] eStoType 対象としているストレージ
|
||||
@details
|
||||
使用する前に一度だけ呼び出してください。
|
||||
2度目を呼び出すとアサートが発生します。
|
||||
nRecordNumは初期化時に作られる管理テーブルのレコード数の決定と、ファイル
|
||||
読み込み時のレコード数に関係します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(Allocator& rAllocator, int nRecordNum, StorageType eStoType);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 解放する
|
||||
@details
|
||||
解放済みの場合に呼び出しても何もせずに終了します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Release();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルを初期化する
|
||||
@details
|
||||
テーブルが存在しなければレコード数nRecordNumのテーブルを作成し、レコード
|
||||
をすべて初期化します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void InitializeValidityStateTable();
|
||||
void InitializePictureTable();
|
||||
void InitializeLegacyTable();
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルを解放する
|
||||
@details
|
||||
テーブルをメモリごと解放します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void ReleaseValidityStateTable();
|
||||
void ReleasePictureTable();
|
||||
void ReleaseLegacyTable();
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルをファイルから読み込む
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath パス
|
||||
@return 結果
|
||||
@details
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じスト
|
||||
レージを指定してください。
|
||||
ファイルが無かった、ファイルが壊れていた場合はfalseを返して失敗します。
|
||||
失敗した場合はInitializePictureTable()された状態になります。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
Result LoadPictureTable(StorageType eStoType, const wchar_t* pPath);
|
||||
Result LoadLegacyTable(StorageType eStoType, const wchar_t* pPath);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルをファイルへ書き出す
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] pPath パス
|
||||
@param[in] bInvalidCrc CRC無効フラグ
|
||||
@return 結果
|
||||
@details
|
||||
eStoTypeはエラーが起こった時の扱いに使用されます。必ずpPathと同じスト
|
||||
レージを指定してください。
|
||||
管理データのヘッダ部にある保存回数をカウントしてから書き込まれます。
|
||||
bInvalidCrcにtrueを指定すると、CRCが不一致した状態で書き込まれます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
Result SavePictureTable(StorageType eStoType, const wchar_t* pPath, bool bInvalidCrc=false);
|
||||
Result SaveLegacyTable(StorageType eStoType, const wchar_t* pPath, bool bInvalidCrc=false);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルが利用可能かチェックする
|
||||
@return 利用可能な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool IsAvailableValidityStateTable() const{ NN_ASSERT(IsInitialized()); return (0 != m_pValidityStateTblData); }
|
||||
bool IsAvailablePictureTable() const{ NN_ASSERT(IsInitialized()); return (0 != m_pPictTblData); }
|
||||
bool IsAvailableLegacyTable() const{ NN_ASSERT(IsInitialized()); return (0 != m_pLegacyTblData); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルの保存回数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetPictureTableSaveCount() const{ NN_ASSERT(IsAvailablePictureTable()); return m_PictTbl.GetHeader()->GetSaveCount(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種テーブルの保存回数を設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetPictureTableSaveCount(u32 nCnt){ NN_ASSERT(IsAvailablePictureTable()); m_PictTbl.GetHeader()->SetSaveCount(nCnt); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 次の写真のフォルダ/ファイル番号を設定する
|
||||
@param[in] rIdxInfo 次のインデックス情報
|
||||
-----------------------------------------------------------------------*/
|
||||
void SeNextIndexInfo(const IndexInfo& rIdxInfo);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データベースのレコード数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ NN_ASSERT(IsInitialized()); return m_nRecordNum; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データベースのレコードを取得する
|
||||
@param[in] nIndex 取得するレコードのインデックス[0,GetRecordNum())
|
||||
@return レコード
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const PictureDbRecord& GetRecord(int nIndex) const;
|
||||
PictureDbRecord& GetRecord(int nIndex){
|
||||
return const_cast<PictureDbRecord&>(static_cast<const PictureDatabase&>(*this).GetRecord(nIndex)); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データベースの空きレコード数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetEmptyRecordNum() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 空のデータベースのレコードのインデックスを探す
|
||||
@param[in] nStartIndex 検索開始インデックス
|
||||
@return 発見したレコードのインデックス[0,GetRecordNum()) 無効な場合はマイナス
|
||||
@details
|
||||
通常、レガシー共に空いているレコードが対象となります。
|
||||
nStartIndexを省略すると先頭から探します。
|
||||
nStartIndexを指定すると、nStartIndex+1から探します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int FindEmptyRecordIndex() const;
|
||||
int FindEmptyRecordIndex(int nStartIndex) const;
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定のレコードを作成する
|
||||
@param[in] eStoType 対象ストレージ
|
||||
@param[in] eImgKind 対象映像種類
|
||||
@param[in] rIdxInfo 指定インデックス情報
|
||||
@return 作成したレコードのインデックス[0,GetRecordNum()) 無効な場合はマイナス
|
||||
@details
|
||||
空のレコードを探して、映像名などを設定したレコードを作成します。
|
||||
作成したレコードは有効フラグがOnで、映像名、拡張子が設定されています。
|
||||
また作成されたレコードの映像名は、対象ストレージに同じ名前のファイルが
|
||||
無いことも確認済みです。
|
||||
rIdxInfoを指定した場合は、指定のインデックス情報でレコードを作成します。
|
||||
既に同じ名前のファイルが存在する場合は失敗します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int CreateNewRecord(StorageType eStoType, ImageKind eImgKind);
|
||||
int CreateNewRecord(StorageType eStoType, ImageKind eImgKind, const IndexInfo& rIdxInfo);
|
||||
//@}
|
||||
|
||||
private:
|
||||
void* Alloc(std::size_t nSize);
|
||||
void Free(void* pAddr);
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
bool IsExistRecord(const IndexInfo& rIdxInfo) const;
|
||||
|
||||
private:
|
||||
Allocator* m_pAllocator;
|
||||
|
||||
imgdb::StorageType m_eStoType;
|
||||
int m_nRecordNum;
|
||||
PictureDbRecord* m_pRecords;
|
||||
|
||||
// 映像妥当性管理データ
|
||||
void* m_pValidityStateTblData;
|
||||
std::size_t m_nValidityStateTblDataSize;
|
||||
ValidityStateTable m_ValidityStateTbl;
|
||||
|
||||
// 写真管理データ
|
||||
void* m_pPictTblData;
|
||||
std::size_t m_nPictTblDataSize;
|
||||
std::size_t m_nPictTblDataRealSize; // 多めに確保した実際のサイズ
|
||||
PictureTable m_PictTbl;
|
||||
|
||||
// レガシー写真管理データ
|
||||
void* m_pLegacyTblData;
|
||||
std::size_t m_nLegacyTblDataSize;
|
||||
std::size_t m_nLegacyTblDataRealSize; // 多めに確保した実際のサイズ
|
||||
LegacyTable m_LegacyTbl;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_PICTURE_DATABASE_H_
|
||||
@ -0,0 +1,313 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbPictureTable.h
|
||||
|
||||
写真管理データ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_PICTURE_TABLE_H_
|
||||
#define IMAGE_DB_PICTURE_TABLE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbIndexInfo.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
#include "ImageDbFaceInfo.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真管理データのヘッダ構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct PictureTableHeader
|
||||
{
|
||||
public:
|
||||
u32 nSignature;
|
||||
u32 nVersion;
|
||||
u32 nSaveCnt;
|
||||
u16 nNumElements;
|
||||
u8 nTargetArchive;
|
||||
u8 reserved0;
|
||||
IndexInfo sIdxInfo;
|
||||
u16 nCrc;
|
||||
u16 nOffset;
|
||||
|
||||
// 識別子の内容
|
||||
static const u32 c_nSignature = 0x514a5531; // '1UJQ'
|
||||
// バージョンの内容
|
||||
static const u32 c_nVersion = 0x315f3030; // '00_1'
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] nExtAreaSize 拡張領域サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(int nRecordNum, u16 nExtAreaSize=0);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 識別子を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSignature() const{ return nSignature; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief バージョンを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetVersion() const{ return nVersion; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存回数を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetSaveCount() const{ return nSaveCnt; }
|
||||
void SetSaveCount(u32 nCnt){ nSaveCnt = nCnt; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコード数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ return nNumElements; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ターゲットアーカイブを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
StorageType GetTargetArchive() const;
|
||||
void SetTargetArchive(StorageType eStoType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インデックス情報を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const IndexInfo& GetIndexInfo() const { return sIdxInfo; }
|
||||
void SetIndexInfo(const IndexInfo& rIdxInfo){ sIdxInfo = rIdxInfo; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief CRC値を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u16 GetCrc() const { return nCrc; }
|
||||
void SetCrc(u16 nCrc){ this->nCrc = nCrc; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 拡張領域の先頭アドレスを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetExtArea() const{
|
||||
return &reinterpret_cast<const u8*>(this)[sizeof(*this)]; }
|
||||
void* GetExtArea(){
|
||||
return const_cast<void*>(static_cast<const PictureTableHeader&>(*this).GetExtArea()); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 拡張領域のサイズを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetExtAreaSize() const{ NN_ASSERT(sizeof(*this) <= nOffset); return (nOffset - sizeof(*this)); }
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真管理データのレコード構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
#pragma pack(push, 4)
|
||||
struct PictureTableRecord
|
||||
{
|
||||
public:
|
||||
ImageInfo sImgInfo; //!< 映像情報
|
||||
FaceInfo sFaceInfo[Const::c_nMaxFaceInfoNum]; //!< 顔情報
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@param[in] eImgKind 初期化対象の映像種類
|
||||
@details
|
||||
eImgKindを省略すると従来通りで初期化されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void Initialize();
|
||||
void Initialize(ImageKind eImgKind);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
名前、値の範囲などをチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const ImageInfo& GetImageInfo() const{ return sImgInfo; }
|
||||
ImageInfo& GetImageInfo(){
|
||||
return const_cast<ImageInfo&>(static_cast<const PictureTableRecord&>(*this).GetImageInfo()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const FaceInfo& GetFaceInfo(int nIdx) const{ NN_ASSERT(Const::c_nMaxFaceInfoNum > nIdx); return sFaceInfo[nIdx]; }
|
||||
FaceInfo& GetFaceInfo(int nIdx){
|
||||
return const_cast<FaceInfo&>(static_cast<const PictureTableRecord&>(*this).GetFaceInfo(nIdx)); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 格納されている顔の数を取得する
|
||||
@return 顔の数 [0~c_nMaxFaceNum]
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetFaceNum() const;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真管理データ
|
||||
@details
|
||||
このクラスは写真管理データの実体を外部から受け取って動作するアクセサです。
|
||||
新規で管理データを用意する場合は ComputeTableSize() 分の確保したメモリを
|
||||
SetInitialTableData() で設定します。
|
||||
ファイルから読み込んだりした既存のデータを使用する場合は、SetExistingTableData()
|
||||
で設定します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class PictureTable
|
||||
{
|
||||
public:
|
||||
//! 最大拡張領域サイズ(バイト単位)
|
||||
static const u16 c_nMaxExtAreaSize = 0xffff;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
PictureTable();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータサイズ求める
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] nExtAreaSize 拡張領域のサイズ(バイト単位)
|
||||
@return サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static std::size_t ComputeTableSize(int nRecordNum, u16 nExtAreaSize=0);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータを取得する
|
||||
@return データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetTableData() const{ return m_pData; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータサイズを取得する
|
||||
@return サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetTableDataSize() const{ return m_nDataSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルデータを初期化して設定する
|
||||
@details
|
||||
指定のレコード数、拡張領域サイズがデータサイズを超えている場合はfalse
|
||||
を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetInitialTableData(void* pData, std::size_t nDataSize, int nRecordNum, u16 nExtAreaSize=0);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 既存の管理テーブルデータを設定する
|
||||
@details
|
||||
設定されたデータのヘッダ部を調査し、無効な場合はfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetExistingTableData(void* pData, std::size_t nDataSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief データの妥当性をチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
サイズ、識別子、CRCなどをチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのヘッダ部を取得する
|
||||
@return ヘッダ部
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const PictureTableHeader* GetHeader() const{
|
||||
NN_NULL_ASSERT(m_pData);
|
||||
return reinterpret_cast<const PictureTableHeader*>(m_pData); }
|
||||
|
||||
PictureTableHeader* GetHeader(){
|
||||
return const_cast<PictureTableHeader*>(static_cast<const PictureTable&>(*this).GetHeader()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのヘッダ部に埋め込まれるCRCを更新する
|
||||
@details
|
||||
現在の内容からCRCを求めます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void UpdateCrc();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのレコード数を取得する
|
||||
@return レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ return GetHeader()->GetRecordNum(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのレコードを取得する
|
||||
@param[in] nIndex 取得するレコードのインデックス [0, GetRecordNum())
|
||||
@return レコード
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const PictureTableRecord* GetRecord(int nIndex) const{
|
||||
NN_ASSERT(0 <= nIndex && nIndex < GetRecordNum());
|
||||
return &GetTopRecord()[nIndex]; }
|
||||
|
||||
PictureTableRecord* GetRecord(int nIndex){
|
||||
return const_cast<PictureTableRecord*>(static_cast<const PictureTable&>(*this).GetRecord(nIndex)); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 使用済みレコード数を数える
|
||||
@return 使用済み管理レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int CountUsedRecordNum() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 未使用レコード数を取得する
|
||||
@return 未使用管理レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int CountEmptyRecordNum() const;
|
||||
|
||||
private:
|
||||
u16 ComputeCrc() const;
|
||||
|
||||
const PictureTableRecord* GetTopRecord() const {
|
||||
return reinterpret_cast<const PictureTableRecord*>(
|
||||
&reinterpret_cast<const u8*>(m_pData)[GetHeader()->nOffset]); }
|
||||
private:
|
||||
void* m_pData;
|
||||
std::size_t m_nDataSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_PICTURE_TABLE_H_
|
||||
169
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbRecord.h
Normal file
169
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbRecord.h
Normal file
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbRecord.h
|
||||
|
||||
映像データベースのレコード
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_RECORD_H_
|
||||
#define IMAGE_DB_RECORD_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbAllocator.h"
|
||||
#include "ImageDbDynamicArray.h"
|
||||
#include "ImageDbImageInfo.h"
|
||||
#include "ImageDbValidityStateTable.h"
|
||||
#include "ImageDbFaceInfo.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像レコード抽象基底クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
class ImageDbRecord
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual const ImageInfo& GetImageInfo() const = 0;
|
||||
virtual ImageInfo& GetImageInfo() = 0;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像妥当性管理レコードを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
virtual const ValidityStateTableRecord& GetValidityStateTableRecord() const = 0;
|
||||
virtual ValidityStateTableRecord& GetValidityStateTableRecord() = 0;
|
||||
//@}
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief レコードリンククラス
|
||||
@details
|
||||
コピー可能
|
||||
レコードの存在する位置を特定するための情報を保持しています。
|
||||
アプリ側では映像に対してこのクラスを使用して映像に指示を出します。
|
||||
リストの要素に実体(コピー)として持たせるため出来るだけ小さくします。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
class ImageDbRecordLink
|
||||
{
|
||||
friend class ImageDatabase;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageDbRecordLink();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ストレージタイプを取得する
|
||||
@return ストレージタイプ
|
||||
-----------------------------------------------------------------------*/
|
||||
StorageType GetStorageType() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像の種類を取得する
|
||||
@return 映像の種類
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageKind GetImageKind() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インデックス情報を取得する
|
||||
@return インデックス情報
|
||||
-----------------------------------------------------------------------*/
|
||||
IndexInfo GetIndexInfo() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影結果日数を取得する
|
||||
@return 撮影結果日数
|
||||
@details
|
||||
200/1/1からの経過日数です。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetDays() const;
|
||||
|
||||
bool operator==(const ImageDbRecordLink& x) const;
|
||||
bool operator!=(const ImageDbRecordLink& x) const;
|
||||
bool operator<(const ImageDbRecordLink& x) const;
|
||||
|
||||
private:
|
||||
void SetStorageType(StorageType eType);
|
||||
|
||||
void SetImageKind(ImageKind eKind);
|
||||
|
||||
void SetIndexInfo(const IndexInfo& rIdxInfo);
|
||||
|
||||
int GetDbRecordIndex() const;
|
||||
void SetDbRecordIndex(int nIdx);
|
||||
|
||||
void SetDays(int nDays);
|
||||
|
||||
private:
|
||||
//----- ビットフィールドA -----//
|
||||
// bit0-17 撮影経過日数 2000/1/1を基準に約±360年まで対応
|
||||
static const int c_nBitFieldADaysBits = 18;
|
||||
static const int c_nBitFieldADaysShift = 0;
|
||||
static const u32 c_nBitFieldADaysMask = ((1UL<<c_nBitFieldADaysBits)-1)<<c_nBitFieldADaysShift;
|
||||
|
||||
// bit18-31 データベース上でのレコードインデックス
|
||||
static const int c_nBitFieldARecordIndexBits = 14;
|
||||
static const int c_nBitFieldARecordIndexShift = c_nBitFieldADaysBits + c_nBitFieldADaysShift;
|
||||
static const u32 c_nBitFieldARecordIndexMask = ((1UL<<c_nBitFieldARecordIndexBits)-1)<<c_nBitFieldARecordIndexShift;
|
||||
|
||||
//----- ビットフィールドB -----//
|
||||
// bit0-1 StorageType列挙型
|
||||
static const int c_nBitFieldBStorageTypeBits = 2;
|
||||
static const int c_nBitFieldBStorageTypeShift = 0;
|
||||
static const u32 c_nBitFieldBStorageTypeMask = ((1UL<<c_nBitFieldBStorageTypeBits)-1)<<c_nBitFieldBStorageTypeShift;
|
||||
|
||||
// bit2-4 ImageKind列挙型
|
||||
static const int c_nBitFieldBImageKindBits = 3;
|
||||
static const int c_nBitFieldBImageKindShift = c_nBitFieldBStorageTypeBits + c_nBitFieldBStorageTypeShift;
|
||||
static const u32 c_nBitFieldBImageKindMask = ((1UL<<c_nBitFieldBImageKindBits)-1)<<c_nBitFieldBImageKindShift;
|
||||
|
||||
// bit5-14 フォルダ番号のインデックス
|
||||
static const int c_nBitFieldBDirIndexBits = 10;
|
||||
static const int c_nBitFieldBDirIndexShift = c_nBitFieldBImageKindBits + c_nBitFieldBImageKindShift;
|
||||
static const u32 c_nBitFieldBDirIndexMask = ((1UL<<c_nBitFieldBDirIndexBits)-1)<<c_nBitFieldBDirIndexShift;
|
||||
|
||||
// bit15-28 ファイル番号のインデックス
|
||||
static const int c_nBitFieldBFileIndexBits = 14;
|
||||
static const int c_nBitFieldBFileIndexShift = c_nBitFieldBDirIndexBits + c_nBitFieldBDirIndexShift;
|
||||
static const u32 c_nBitFieldBFileIndexMask = ((1UL<<c_nBitFieldBFileIndexBits)-1)<<c_nBitFieldBFileIndexShift;
|
||||
|
||||
|
||||
private:
|
||||
union {
|
||||
u64 m_nBitField;
|
||||
struct {
|
||||
u32 m_nBitFieldA;
|
||||
u32 m_nBitFieldB;
|
||||
};
|
||||
};
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
//! レコードリンクリスト
|
||||
typedef DynamicArray< ImageDbRecordLink, XAllocator<ImageDbRecordLink> > RecordLinkList;
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_RECORD_H_
|
||||
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbRecordParam.h
|
||||
|
||||
映像レコード変更可能パラメータ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_RECORD_PARAM_H_
|
||||
#define IMAGE_DB_RECORD_PARAM_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
#include "ImageDbFaceInfo.h"
|
||||
#include "ImageDbRecord.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief レガシー映像レコードパラメータクラス(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct ImageDbRecordParamLegacy
|
||||
{
|
||||
s32 nFavoriteOrder;
|
||||
LegacyFavoriteType eFavoriteType;
|
||||
LegacyImageType eImageType;
|
||||
LegacyKeyType eKey;
|
||||
u8 reserved;
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 構造体を初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像レコードパラメータクラス(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
#pragma pack(push, 4)
|
||||
struct ImageDbRecordParam
|
||||
{
|
||||
DateTimeSeconds sShotSeconds; // 撮影日時
|
||||
u32 nTitleUniqueId; // タイトルユニークID
|
||||
SaveProcessType eSaveProcess; // 保存過程の種類
|
||||
HandleTypeBit eHandleTypeBit; // 取り扱いビット
|
||||
DistinctionTypeBit eDistinctionFlag; // 写真特徴フラグ DistinctionTypeBit列挙型
|
||||
BodyIdTypeBit eValidBodyIdFlag; // 有効な本体IDのフラグ BodyIdTypeBit列挙型の論理和
|
||||
u32 nBodyId[BodyIdTypeNum]; // 本体ID
|
||||
ShootingType eShootingType; // 撮影タイプ
|
||||
u8 reserved[3];
|
||||
|
||||
// 顔情報
|
||||
imgdb::FaceInfo sFaceInfo[Const::c_nMaxFaceInfoNum];
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 構造体を初期化する
|
||||
@param[in] eImgKind 初期化対象の映像種類
|
||||
@details
|
||||
ここで初期化した値は写真から情報が取れなかったときなどの初期値になります。
|
||||
eImgKindを省略すると写真として初期化されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void Initialize();
|
||||
void Initialize(ImageKind eImgKind);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影日時を取得/設定する(2000/01/01 0:0:0からの経過秒数)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetShotSeconds() const{ return sShotSeconds; }
|
||||
void SetShotSeconds(const DateTimeSeconds& rDTSecs){ sShotSeconds = rDTSecs; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetTitleUniqueId() const{ return nTitleUniqueId; }
|
||||
void SetTitleUniqueId(u32 nUId){ nTitleUniqueId = nUId; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存過程タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
SaveProcessType GetSaveProcessType() const{ return eSaveProcess; }
|
||||
void SetSaveProcessType(SaveProcessType eType){ eSaveProcess = eType; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 取り扱いフラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
HandleTypeBit GetHandleTypeBit() const{ return eHandleTypeBit; }
|
||||
void SetHandleTypeBit(HandleTypeBit eBit){ eHandleTypeBit = eBit; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真特徴タイプのビットフラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
DistinctionTypeBit GetDistinctionTypeBit() const{ return eDistinctionFlag; }
|
||||
void SetDistinctionTypeBit(DistinctionTypeBit eBit){ eDistinctionFlag = eBit; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 本体IDの取得/設定/チェック/リセットを行う
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetBodyId(BodyIdType eType) const;
|
||||
void SetBodyId(BodyIdType eType, u32 nId);
|
||||
bool IsValidBodyId(BodyIdType eType) const;
|
||||
BodyIdTypeBit GetValidBodyIdBit() const;
|
||||
void ResetBodyId(BodyIdType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ShootingType GetShootingType() const{ return eShootingType; }
|
||||
void SetShootingType(ShootingType eType){ eShootingType = eType; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const FaceInfo& GetFaceInfo(int nIdx) const{ NN_ASSERT(Const::c_nMaxFaceInfoNum > nIdx); return sFaceInfo[nIdx]; }
|
||||
FaceInfo& GetFaceInfo(int nIdx){
|
||||
return const_cast<FaceInfo&>(static_cast<const ImageDbRecordParam&>(*this).GetFaceInfo(nIdx)); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 格納されている顔の数を取得する
|
||||
@return 顔の数 [0, PictureDbFileRecord::c_nMaxFaceNum]
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetFaceNum() const;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_RECORD_PARAM_H_
|
||||
@ -0,0 +1,130 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbRestore.h
|
||||
|
||||
写真データベース修復機能
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_RESTORE_H_
|
||||
#define IMAGE_DB_RESTORE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/fs.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "JpegMpDecoder.h"
|
||||
#include "ImageDbPictureDatabase.h"
|
||||
#include "ImageDbUtility.h"
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真データベース復元機能クラス
|
||||
@details
|
||||
インスタンス不可の静的メソッドを提供するだけのクラスです。
|
||||
*---------------------------------------------------------------------------*/
|
||||
class ImageDbRestore
|
||||
{
|
||||
private:
|
||||
// 生成不可
|
||||
ImageDbRestore();
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真データベースを修復する
|
||||
@param[in] eStoType ストレージタイプ
|
||||
@param[in] bNotEnumTwl TWL領域のファイル列挙は行わないフラグ
|
||||
@param[in] bNotEnumCtr CTR領域のファイル列挙は行わないフラグ
|
||||
@param[out] rPictDb 修復結果の写真データベース
|
||||
@details
|
||||
存在する写真ファイルから管理ファイルを作成します。すべての写真を出来る
|
||||
限り管理ファイルへ登録するように処理しますが、管理数制限を超えた場合、
|
||||
ストレージによって以下の処理になります。
|
||||
・NAND 管理できなかった写真(JPG,MPO)はすべてく削除する
|
||||
・SD 管理できなかった写真(JPG,MPO)はすべてくそのままにする
|
||||
|
||||
bNotEnumTwl、bNotEnumCtrにtrueを指定すると、その領域に関してはファイル
|
||||
の存在から管理ファイルの登録を行いません。
|
||||
TWL側とCTR側の両方の管理ファイルが無い場合は、ともにfalseを指定すること
|
||||
で双方の側のファイルの存在から修復が行われます。その際rPictDbは初期化済
|
||||
みの未使用状態にしておいてください。
|
||||
どちらか一方の管理ファイルが存在するのであれば、ある側のフラグをtrueにす
|
||||
ることで、ファイルチェックが省かれます。その際rPictDbDataは存在する方の
|
||||
管理ファイルの内容を反映した状態にしておいてください。
|
||||
戻り値は基本的にResultSuccessしか返しませんが、StopRestore()で中断した
|
||||
場合だけはResultErrorStoppedを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
static Result RestorePictureDatabase(
|
||||
StorageType eStoType, bool bNotRestoreTwl, bool bNotRestoreCtr,
|
||||
PictureDatabase& rPictDb);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 修復処理の中止要求を行う
|
||||
@details
|
||||
別スレッドから処理中止を要求します。
|
||||
中止要求は修復処理関数が内部処理の直前でクリアします。そのため確実に中止
|
||||
するには本関数を呼び出し続ける必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
static void StopRestore();
|
||||
|
||||
public:
|
||||
static bool DeleteFileIfZeroByte(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec,
|
||||
bool* pDelCtr=0, bool* pDelTwl=0);
|
||||
|
||||
static void SyncPictureDatabaseRecord(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
|
||||
private:
|
||||
// 中止要求関連
|
||||
static bool IsRequestStop();
|
||||
static void ResetRequestStop();
|
||||
|
||||
static void RestorePictureDatabaseTwl(
|
||||
StorageType eStoType, PictureDatabase& rPictDb);
|
||||
static void RestorePictureDatabaseDirTwl(
|
||||
StorageType eStoType, PictureDatabase& rPictDb,
|
||||
const IndexInfo& rIdxInfo);
|
||||
static void RestorePictureDatabaseFileTwl(
|
||||
StorageType eStoType, PictureDatabase& rPictDb,
|
||||
const IndexInfo& rIdxInfo);
|
||||
|
||||
static void RestorePictureDatabaseCtr(
|
||||
StorageType eStoType, PictureDatabase& rPictDb);
|
||||
static void RestorePictureDatabaseDirCtr(
|
||||
StorageType eStoType, PictureDatabase& rPictDb,
|
||||
const IndexInfo& rIdxInfo);
|
||||
static void RestorePictureDatabaseFileCtr(
|
||||
StorageType eStoType, PictureDatabase& rPictDb,
|
||||
const IndexInfo& rIdxInfo, ImageKind eImgKind);
|
||||
|
||||
static void SyncPictureDatabase(
|
||||
StorageType eStoType, PictureDatabase& rPictDb);
|
||||
// static void SyncPictureDatabaseRecord(
|
||||
// StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
static void SyncPictureDatabaseRecordAvailableTwlOnly(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
static void SyncPictureDatabaseRecordAvailableCtrOnly(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
static void SyncPictureDatabaseRecordAvailableCtrOnlyJpeg(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
static void SyncPictureDatabaseRecordAvailableCtrOnlyMp(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
|
||||
static void ExtractPictureDatabaseInfo(
|
||||
StorageType eStoType, PictureDatabase& rPictDb);
|
||||
static void ExtractPictureDatabaseInfoRecord(
|
||||
StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
|
||||
// static void DeleteFileIfZeroByte(
|
||||
// StorageType eStoType, PictureDbRecord& rPictRec);
|
||||
|
||||
private:
|
||||
// 処理中止要求
|
||||
static volatile bool m_bReqStop;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_RESTORE_H_
|
||||
126
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbResult.h
Normal file
126
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbResult.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbResult.h
|
||||
|
||||
映像データベース結果定義
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_RESULT_H_
|
||||
#define IMAGE_DB_RESULT_H_
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 結果列挙型
|
||||
@details
|
||||
システム用エラーはImageDbが内部で使用しているエラーです。<BR>
|
||||
アプリ側には返されないので気にする必要はありません。<BR>
|
||||
|
||||
ResultError<BR>
|
||||
未カテゴリの一般エラーです。<BR>
|
||||
必然的なエラーの場合などに利用されています。<BR>
|
||||
このエラーが返された場合は、どこか別のところでより具体的なエラーが返って
|
||||
いることがあります。<BR>
|
||||
|
||||
ResultErrorInvalidParam<BR>
|
||||
引数などのパラメータが無効な場合などに発生します。<BR>
|
||||
ライブラリの使い方に問題があるため、パラメータを見なおして発生しないよう
|
||||
にしてください。<BR>
|
||||
|
||||
ResultErrorOverNumImages<BR>
|
||||
ImageDbが扱える映像数を超えて、写真などを登録しようとした場合に発生します。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
|
||||
ResultErrorOverNumDcf<BR>
|
||||
DCF規格の限界を超え(DCIM以下に保存される映像の名前がすべて使われ)て、写真
|
||||
が登録出来ないときに発生します。<BR>
|
||||
SDカード対しては普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
NANDに対して発生した場合はFATALエラーとして処理してください。<BR>
|
||||
|
||||
ResultErrorFileOperationFailure<BR>
|
||||
ファイルのオープン、リード、ライトなどでの予期しないファイル操作失敗エラーです。<BR>
|
||||
SDカードで発生した場合はメッセージを出すなどして、プログラムが続行するように
|
||||
作成する必要があります。<BR>
|
||||
NANDではシステム側でFATALエラーが発動するので、この結果が返ることは無いかと思い
|
||||
ますが、一応FATALエラーとして扱ってください。<BR>
|
||||
|
||||
ResultErrorInvalidFile<BR>
|
||||
読み込んだ映像が規格外、壊れているなどの場合に発生するエラーです。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
|
||||
ResultErrorTooLargeFile<BR>
|
||||
読み込んだ映像が大きすぎて失敗した場合に発生するエラーです。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
|
||||
ResultErrorNotExistStorage<BR>
|
||||
SDカードを認識していないのに、SDカードへの要求が発生した場合に起こるエラーです。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
NANDでは発生しません。<BR>
|
||||
|
||||
ResultErrorWriteProtect
|
||||
ライトプロテクトされているSDカードに対して書き込み処理が発生した場合に起
|
||||
こるエラーです。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
NANDでは発生しません。<BR>
|
||||
|
||||
ResultErrorInsufficientStorageSpace<BR>
|
||||
ストレージの空き不足で、写真の保存などが失敗したときに発生するエラーです。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
|
||||
ResultErrorStopped<BR>
|
||||
StopProcess()やStopCollect()などで処理が中断されたとき返ってくるエラーです。<BR>
|
||||
アプリ側が意図的に起こしたエラーとなるため、発生しても問題ないようにプログ
|
||||
ラムする必要があります。<BR>
|
||||
|
||||
ResultErrorPermissionDenied<BR>
|
||||
権限がないため処理に失敗したときに返ってくるエラーです。<BR>
|
||||
対象外の写真を削除しようとした場合などに発生します。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
|
||||
ResultErrorReadOnlyDbFile<BR>
|
||||
管理ファイルが読み取り専用属性のときに返ってくるエラーです。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。<BR>
|
||||
NANDでは発生しません。<BR>
|
||||
|
||||
ResultErrorNotAvailableStorage<BR>
|
||||
SDカードスロットに挿されているものが扱えないときに発生するエラーです。<BR>
|
||||
マルチメディアカードなどを差した時などに発生します。<BR>
|
||||
通常の利用でも普通に現れるエラーのため、発生しても問題ないようにプログラム
|
||||
する必要があります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
enum Result {
|
||||
ResultSuccess = 0, //!< 成功
|
||||
|
||||
ResultError = 1, //!< エラー全般
|
||||
ResultErrorInvalidParam = 2, //!< 無効なパラメータ
|
||||
ResultErrorOverNumImages = 3, //!< 写真の管理上限を超えた
|
||||
ResultErrorOverNumDcf = 4, //!< 写真のDCF規格の上限を超えた
|
||||
ResultErrorFileOperationFailure = 5, //!< ファイル操作失敗
|
||||
ResultErrorInvalidFile = 6, //!< 無効なファイル
|
||||
ResultErrorTooLargeFile = 7, //!< ファイルサイズが大きすぎる
|
||||
ResultErrorNotExistStorage = 8, //!< ストレージが存在しなかった(SDカードが刺さっていない)
|
||||
ResultErrorWriteProtect = 9, //!< ライトプロテクトされている(SDカードがロックされている)
|
||||
ResultErrorInsufficientStorageSpace = 10, //!< NANDやSDの空き不足
|
||||
ResultErrorStopped = 11, //!< StopProcess()による中断
|
||||
ResultErrorPermissionDenied = 12, //!< 権限がない
|
||||
ResultErrorReadOnlyDbFile = 13, //!< 管理ファイルが読み取り専用属性になっている
|
||||
ResultErrorNotAvailableStorage = 14, //!< 利用可能なストレージでない(壊れたSDカードなど)
|
||||
|
||||
// システム用エラー関連
|
||||
ResultSysErrorNeedRestore = -1 //!< 管理ファイルの修復が必要(システム用エラー)
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_RESULT_H_
|
||||
@ -0,0 +1,291 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbSearchObject.h
|
||||
|
||||
映像データベース検索
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_SEARCH_OBJECT_H_
|
||||
#define IMAGE_DB_SEARCH_OBJECT_H_
|
||||
|
||||
#include <limits>
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbRecord.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
class ImageDatabase;
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベース検索オブジェクトクラス
|
||||
@details
|
||||
検索オブジェクトを使用する場合はImageDatabase::CreateSearchObject()で初期化
|
||||
する必要があります。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ImageDbSearchObject : private nn::util::NonCopyable<ImageDbSearchObject>
|
||||
{
|
||||
friend class ImageDatabase;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
ImageDbSearchObject();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索結果のメモリを予約する
|
||||
@param[in] nNum 予約する検索結果数
|
||||
@details
|
||||
nNumで予約数を指定すると、その分のメモリが予め確保された状態になります。
|
||||
Search()などで検索を行ったときに、検索結果が予約数内に収まっている場合
|
||||
は追加のメモリ確保は発生しません。
|
||||
予約数を超えた場合は、超えた分だけのメモリが追加確保されます。
|
||||
検索結果をクリアなどした場合、予約したメモリ分だけは確保された状態にな
|
||||
ります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void ReserveRecord(int nNum);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索結果をインデックスで取得する
|
||||
@param[in] nIndex インデックス [0, GetNum())
|
||||
@return レコードリンク
|
||||
@details
|
||||
無効なインデックスを指定した場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
const ImageDbRecordLink& GetRecord(int nIndex) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索結果をクリアする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ClearRecord();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定インデックスの検索結果を削除する
|
||||
@param[in] nIndex インデックス [0, GetRecordNum())
|
||||
-----------------------------------------------------------------------*/
|
||||
void EraseRecord(int nIndex);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定インデックスの位置へレコードリンクを挿入する
|
||||
@param[in] nIndex インデックス [0, GetRecordNum()]
|
||||
@details
|
||||
レコードの挿入は非推奨のため、挿入する場合は辻褄が合うようにアプリ側で
|
||||
使用してください。
|
||||
nIndexがゼロ未満の場合は先頭、GetRecordNum()より大きい場合は末尾に追加
|
||||
されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void InsertRecord(int nIndex, const ImageDbRecordLink& rLink);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索結果の数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 指定のレコードリンクを探す
|
||||
@param[in] rLink 探すレコードリンク
|
||||
@return 見つかったrLinkのインデックス マイナスの場合は存在しない
|
||||
-----------------------------------------------------------------------*/
|
||||
int FindRecord(const ImageDbRecordLink& rLink) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 映像情報を検索する
|
||||
@param[in] rDTSecsStart 撮影時間の開始 省略時はDateTimeSeconds::GetMinSeconds()
|
||||
@param[in] rDTSecsEnd 撮影時間の終了 省略時はDateTimeSeconds::GetMaxSeconds()
|
||||
@param[in] eStoTypeBit ストレージタイプ 省略時はStorageTypeBitAll
|
||||
@param[in] eImgKindBit 映像データの種類 省略時はImageKindBitKnownAll
|
||||
@param[in] eShootTypeBit 撮影タイプ 省略時はShootingTypeAll
|
||||
@param[in] eDisTypeBit 写真特徴タイプ 省略時はDistinctionTypeBitNone
|
||||
@param[in] nMinFaceNum 最低顔数 省略時は0
|
||||
@param[in] nMaxFaceNum 最大顔数 省略時はPictureDbFileRecord::c_nMaxFaceNum
|
||||
@param[in] pred 検索条件プレディケート
|
||||
@details
|
||||
nSecStartにc_nSecondYoungestを指定すると最も古い映像からが対象になり、
|
||||
nSecEndにc_nSecondOldestを指定すると最も新しい映像が対象になります。
|
||||
[nSecStart, nSecEnd]の範囲の撮影時間になります。
|
||||
eDisTypeBitで特徴が無い映像も対象にしたい場合はDistinctionTypeBitNoneを
|
||||
指定します。
|
||||
自由な検索を行うにはpredを使用します。predは関数オブジェクトで、検索条件を
|
||||
bool operator()(const ImageDatabase&, const ImageDbRecordLink&)関数として
|
||||
実装します。検索結果を対象とする場合はtrue、しない場合はfalseを返すように
|
||||
してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
// フルスペック検索
|
||||
void Search(
|
||||
const DateTimeSeconds& rDTSecsStart, const DateTimeSeconds& rDTSecsEnd,
|
||||
StorageTypeBit eStoTypeBit,
|
||||
ImageKindBit eImgKindBit,
|
||||
ShootingTypeBit eShootTypeBit,
|
||||
DistinctionTypeBit eDisTypeBit,
|
||||
int nMinFaceNum, int nMaxFaceNum);
|
||||
// 撮影時間無視の全条件検索
|
||||
void Search(
|
||||
StorageTypeBit eStoTypeBit,
|
||||
ImageKindBit eImgKindBit,
|
||||
ShootingTypeBit eShootTypeBit,
|
||||
DistinctionTypeBit eDisTypeBit,
|
||||
int nMinFaceNum, int nMaxFaceNum);
|
||||
// 撮影時間無視、撮影情報無視の検索
|
||||
void Search(
|
||||
StorageTypeBit eStoTypeBit,
|
||||
ImageKindBit eImgKindBit);
|
||||
// ストレージの映像すべて検索
|
||||
void Search(StorageTypeBit eStoTypeBit);
|
||||
// すべて検索
|
||||
void Search();
|
||||
// カスタム条件検索
|
||||
template<typename Func>
|
||||
void Search(Func pred);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索結果を絞り込む
|
||||
@param[out] rSearch 絞り込んだ検索結果を格納するオブジェクト
|
||||
@param[in] rDTSecsStart 撮影時間の開始 省略時はDateTimeSeconds::GetMinSeconds()
|
||||
@param[in] rDTSecsEnd 撮影時間の終了 省略時はDateTimeSeconds::GetMaxSeconds()
|
||||
@param[in] eStoTypeBit ストレージタイプ 省略時はStorageTypeBitAll
|
||||
@param[in] eImgKindBit 映像データの種類 省略時はImageKindBitKnownAll
|
||||
@param[in] eShootTypeBit 撮影タイプ 省略時はShootingTypeAll
|
||||
@param[in] eDisTypeBit 写真特徴タイプ 省略時はDistinctionTypeBitNone
|
||||
@param[in] nMinFaceNum 最低顔数 省略時は0
|
||||
@param[in] nMaxFaceNum 最大顔数 省略時はPictureDbFileRecord::c_nMaxFaceNum
|
||||
@param[in] pred 検索条件プレディケート
|
||||
@details
|
||||
既にある検索結果から、さらに検索条件を指定して、絞り込んだ結果の検索オブ
|
||||
ジェクトを生成します。
|
||||
検索条件を変えたくない場合は、コメントにあるデフォルト値を指定してください。
|
||||
自由な検索を行うにはpredを使用します。predは関数オブジェクトで、検索条件を
|
||||
bool operator()(const ImageDatabase&, const ImageDbRecordLink&)関数として
|
||||
実装します。検索結果を対象とする場合はtrue、しない場合はfalseを返すように
|
||||
してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
// フルスペック絞り込み検索
|
||||
void SearchRefinement(
|
||||
ImageDbSearchObject& rSearch,
|
||||
const DateTimeSeconds& rDTSecsStart, const DateTimeSeconds& rDTSecsEnd,
|
||||
StorageTypeBit eStoTypeBit,
|
||||
ImageKindBit eImgKindBit,
|
||||
ShootingTypeBit eShootTypeBit,
|
||||
DistinctionTypeBit eDisTypeBit,
|
||||
int nMinFaceNum, int nMaxFaceNum) const;
|
||||
// 撮影時間無視の全条件絞り込み検索
|
||||
void SearchRefinement(
|
||||
ImageDbSearchObject& rSearch,
|
||||
StorageTypeBit eStoTypeBit,
|
||||
ImageKindBit eImgKindBit,
|
||||
ShootingTypeBit eShootTypeBit,
|
||||
DistinctionTypeBit eDisTypeBit,
|
||||
int nMinFaceNum, int nMaxFaceNum) const;
|
||||
// 撮影時間無視、撮影情報無視の絞り込み検索
|
||||
void SearchRefinement(
|
||||
ImageDbSearchObject& rSearch,
|
||||
StorageTypeBit eStoTypeBit,
|
||||
ImageKindBit eImgKindBit) const;
|
||||
// ストレージの映像すべて絞り込み検索
|
||||
void SearchRefinement(
|
||||
ImageDbSearchObject& rSearch,
|
||||
StorageTypeBit eStoTypeBit) const;
|
||||
// カスタム条件絞り込み検索
|
||||
template<typename Func>
|
||||
void SearchRefinement(ImageDbSearchObject& rSearch, Func pred) const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
template<typename TList, typename Func>
|
||||
void SearchInternal(
|
||||
const ImageDatabase& rOwnerDb, const TList& rBaseList, Func pred);
|
||||
|
||||
private:
|
||||
const ImageDatabase* m_pOwnerDb;
|
||||
|
||||
// ストレージとレコード種類の検索結果マスク
|
||||
StorageTypeBit m_eStoTypeBit;
|
||||
ImageKindBit m_eImgKindBit;
|
||||
|
||||
RecordLinkList m_lRecordLinkList;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
映像情報を検索する
|
||||
---------------------------------------------------------------------------*/
|
||||
// カスタム検索
|
||||
template<typename Func>
|
||||
void ImageDbSearchObject::Search(Func pred)
|
||||
{
|
||||
NN_NULL_ASSERT(m_pOwnerDb);
|
||||
|
||||
SearchInternal(*m_pOwnerDb, m_pOwnerDb->m_lRecordLinkList, pred);
|
||||
|
||||
int nStoTypeBit = StorageTypeBitNone;
|
||||
int nImgKindBit = ImageKindBitNone;
|
||||
for(RecordLinkList::const_iterator it = m_lRecordLinkList.begin(); m_lRecordLinkList.end() != it; ++it){
|
||||
const ImageDbRecordLink& rLink = *it;
|
||||
nStoTypeBit |= 1 << rLink.GetStorageType();
|
||||
nImgKindBit |= 1 << rLink.GetImageKind();
|
||||
}
|
||||
m_eStoTypeBit = static_cast<StorageTypeBit>(nStoTypeBit);
|
||||
m_eImgKindBit = static_cast<ImageKindBit>(nImgKindBit);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
検索結果を絞り込む
|
||||
---------------------------------------------------------------------------*/
|
||||
// カスタム絞り込み検索
|
||||
template<typename Func>
|
||||
void ImageDbSearchObject::SearchRefinement(
|
||||
ImageDbSearchObject& rSearch, Func pred) const
|
||||
{
|
||||
rSearch.SearchInternal(
|
||||
*m_pOwnerDb, m_lRecordLinkList, pred);
|
||||
|
||||
const RecordLinkList& rRecLinkList = rSearch.m_lRecordLinkList;
|
||||
int nStoTypeBit = StorageTypeBitNone;
|
||||
int nImgKindBit = ImageKindBitNone;
|
||||
for(RecordLinkList::const_iterator it = rRecLinkList.begin(); rRecLinkList.end() != it; ++it){
|
||||
const ImageDbRecordLink& rLink = *it;
|
||||
nStoTypeBit |= 1 << rLink.GetStorageType();
|
||||
nImgKindBit |= 1 << rLink.GetImageKind();
|
||||
}
|
||||
rSearch.m_eStoTypeBit = static_cast<StorageTypeBit>(nStoTypeBit);
|
||||
rSearch.m_eImgKindBit = static_cast<ImageKindBit>(nImgKindBit);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
指定のリストから検索する
|
||||
--------------------------------------------------------------------------*/
|
||||
template<typename TList, typename Func>
|
||||
void ImageDbSearchObject::SearchInternal(
|
||||
const ImageDatabase& rOwnerDb, const TList& rBaseList, Func pred)
|
||||
{
|
||||
m_lRecordLinkList.clear();
|
||||
m_lRecordLinkList.reserve(rBaseList.size());
|
||||
|
||||
// 合致するものだけをリストに登録していく
|
||||
for(typename TList::const_iterator it = rBaseList.begin(); rBaseList.end() != it; ++it){
|
||||
const ImageDbRecordLink& rLink = *it;
|
||||
if(!pred(*m_pOwnerDb, rLink)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// ここまで来たなら条件に合致したので記録する
|
||||
m_lRecordLinkList.push_back(rLink);
|
||||
}
|
||||
|
||||
m_pOwnerDb = &rOwnerDb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_SEARCH_OBJECT_H_
|
||||
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbSingleton.h
|
||||
|
||||
シングルトン
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_SINGLETON_H_
|
||||
#define IMAGE_DB_SINGLETON_H_
|
||||
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbAllocator.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像データベースクラス
|
||||
@details
|
||||
NANDやSDカードに保存されている写真(動画)を管理するための機能を提供します。
|
||||
TWLのTCLライブラリの管理ファイル操作関連に似せています。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
template<typename T>
|
||||
class Singleton
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インスタンスを生成する
|
||||
@details
|
||||
既に生成済みの場合は何も行ないません。
|
||||
-----------------------------------------------------------------------*/
|
||||
static void CreateInstance(Allocator* pAllocator=0){
|
||||
if(0 == m_pInstance){
|
||||
m_pAllocator = pAllocator;
|
||||
if(0 == m_pAllocator){
|
||||
m_pAllocator = GetAllocator();
|
||||
}
|
||||
|
||||
NN_NULL_ASSERT(m_pAllocator);
|
||||
m_pInstance = m_pAllocator->AllocAndConstruct<T>(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インスタンスを解放する
|
||||
@details
|
||||
既に解放済みの場合は何も行ないません。
|
||||
-----------------------------------------------------------------------*/
|
||||
static void DestroyInstance(){
|
||||
if(0 != m_pInstance){
|
||||
T* pTmp = m_pInstance;
|
||||
m_pInstance = 0;
|
||||
|
||||
NN_NULL_ASSERT(m_pAllocator);
|
||||
m_pAllocator->DestructAndFree<T>(pTmp, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インスタンスを取得する
|
||||
@return インスタンスのポインタ
|
||||
@details
|
||||
生成されていない場合はアサートが発生しヌルを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
static T* GetInstance(){ NN_ASSERT(IsExistInstance()); return m_pInstance; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief インスタンスが存在するかチェックする
|
||||
@return 存在する場合はtrue
|
||||
@details
|
||||
CreateInstance()でインスタンスが生成されている場合はtrueを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
static bool IsExistInstance(){ return (0 != m_pInstance); }
|
||||
|
||||
protected:
|
||||
virtual ~Singleton(){ NN_ASSERT(!IsExistInstance()); /*意図的に解放してもらうためのチェック*/ }
|
||||
|
||||
private:
|
||||
static T* m_pInstance;
|
||||
static Allocator* m_pAllocator;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
template<typename T>
|
||||
T* Singleton<T>::m_pInstance = 0;
|
||||
|
||||
template<typename T>
|
||||
Allocator* Singleton<T>::m_pAllocator = 0;
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_SINGLETON_H_
|
||||
400
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbTypes.h
Normal file
400
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/ImageDbTypes.h
Normal file
@ -0,0 +1,400 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbTypes.h
|
||||
|
||||
映像データベース定義
|
||||
|
||||
写真=Picture
|
||||
動画=Movie
|
||||
映像=Image(Picture+Movie)
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_TYPES_H_
|
||||
#define IMAGE_DB_TYPES_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
//! ストレージタイプ
|
||||
enum StorageType {
|
||||
StorageTypeNand = 0, //!< NAND
|
||||
StorageTypeSd, //!< SDカード
|
||||
|
||||
StorageTypeReserved2,
|
||||
StorageTypeReserved3,
|
||||
|
||||
StorageTypeNum = StorageTypeReserved2
|
||||
};
|
||||
|
||||
//! ストレージのビットフラグ
|
||||
enum StorageTypeBit {
|
||||
StorageTypeBitNone = 0,
|
||||
|
||||
StorageTypeBitNand = 1 << StorageTypeNand, //!< NAND
|
||||
StorageTypeBitSd = 1 << StorageTypeSd, //!< SDカード
|
||||
|
||||
StorageTypeBitAll = StorageTypeBitNand
|
||||
| StorageTypeBitSd
|
||||
};
|
||||
|
||||
|
||||
//! 映像データの種類
|
||||
enum ImageKind {
|
||||
ImageKindUnknown = 0, //!< 不明
|
||||
|
||||
ImageKindJpeg, //!< JPEG
|
||||
ImageKindMp, //!< MP
|
||||
ImageKindMJpeg, //!< モーションJPEG
|
||||
|
||||
ImageKindReserved4,
|
||||
ImageKindReserved5,
|
||||
ImageKindReserved6,
|
||||
ImageKindReserved7,
|
||||
|
||||
ImageKindNum = ImageKindReserved4
|
||||
};
|
||||
|
||||
//! 映像データの種類のビットフラグ
|
||||
enum ImageKindBit {
|
||||
ImageKindBitNone = 0,
|
||||
|
||||
ImageKindBitUnknown = 1 << ImageKindUnknown, //!< 不明
|
||||
|
||||
ImageKindBitJpeg = 1 << ImageKindJpeg, //!< JPEG
|
||||
ImageKindBitMp = 1 << ImageKindMp, //!< MP
|
||||
ImageKindBitMJpeg = 1 << ImageKindMJpeg, //!< モーションJPEG
|
||||
|
||||
//! 写真データ
|
||||
ImageKindBitPicture = ImageKindBitJpeg
|
||||
| ImageKindBitMp,
|
||||
//! 動画データ
|
||||
ImageKindBitMovie = ImageKindBitMJpeg,
|
||||
|
||||
//! 既知の種類すべて
|
||||
ImageKindBitKnownAll = ImageKindBitPicture
|
||||
| ImageKindBitMovie,
|
||||
|
||||
ImageKindBitAll = ImageKindBitUnknown
|
||||
| ImageKindBitKnownAll
|
||||
};
|
||||
|
||||
|
||||
//! 撮影タイプ
|
||||
enum ShootingType {
|
||||
ShootingTypePhotoNormal = 0, //!< 写真 通常設定
|
||||
ShootingTypePhotoFace, //!< 写真 顔合成
|
||||
ShootingTypePhotoEffect, //!< 写真 エフェクト
|
||||
ShootingTypePhotoDayDream, //!< 写真 白昼夢
|
||||
ShootingTypePhotoToy, //!< 写真 トイカメラ
|
||||
ShootingTypePhotoAfterimage, //!< 写真 残像
|
||||
ShootingTypePhotoFramelate, //!< 写真 フレームレート(暗いとこ撮影)
|
||||
ShootingTypePhotoQuestion, //!< 写真 ?ボックス
|
||||
ShootingTypePhotoManual, //!< 写真 こだわり設定
|
||||
|
||||
ShootingTypeMovieNormal, //!< 動画 ノーマル
|
||||
ShootingTypeMovieFramelate, //!< 動画 フレームレート(暗いとこ撮影)
|
||||
ShootingTypeMovieManual, //!< 動画 こだわり
|
||||
|
||||
ShootingTypeReserve0, //!< 予約
|
||||
ShootingTypeReserve1, //!< 予約
|
||||
ShootingTypeReserve2, //!< 予約
|
||||
ShootingTypeReserve3, //!< 予約
|
||||
|
||||
ShootingTypeNum
|
||||
};
|
||||
|
||||
//! 撮影タイプのビットフラグ
|
||||
enum ShootingTypeBit {
|
||||
ShootingTypeBitPhotoNormal = 1 << ShootingTypePhotoNormal, //!< 写真 通常設定
|
||||
ShootingTypeBitPhotoFace = 1 << ShootingTypePhotoFace, //!< 写真 顔合成
|
||||
ShootingTypeBitPhotoEffect = 1 << ShootingTypePhotoEffect, //!< 写真 エフェクト
|
||||
ShootingTypeBitPhotoDayDream = 1 << ShootingTypePhotoDayDream, //!< 写真 白昼夢
|
||||
ShootingTypeBitPhotoToy = 1 << ShootingTypePhotoToy, //!< 写真 トイカメラ
|
||||
ShootingTypeBitPhotoAfterimage = 1 << ShootingTypePhotoAfterimage, //!< 写真 残像
|
||||
ShootingTypeBitPhotoFramelate = 1 << ShootingTypePhotoFramelate, //!< 写真 フレームレート(暗いとこ撮影)
|
||||
ShootingTypeBitPhotoQuestion = 1 << ShootingTypePhotoQuestion, //!< 写真 ?ボックス
|
||||
ShootingTypeBitPhotoManual = 1 << ShootingTypePhotoManual, //!< 写真 こだわり設定
|
||||
|
||||
ShootingTypeBitMovieNormal = 1 << ShootingTypeMovieNormal, //!< 動画 ノーマル
|
||||
ShootingTypeBitMovieFramelate = 1 << ShootingTypeMovieFramelate, //!< 動画 フレームレート(暗いとこ撮影)
|
||||
ShootingTypeBitMovieManual = 1 << ShootingTypeMovieManual, //!< 動画 こだわり
|
||||
|
||||
ShootingTypeBitReserve0 = 1 << ShootingTypeReserve0, //!< 予約
|
||||
ShootingTypeBitReserve1 = 1 << ShootingTypeReserve1, //!< 予約
|
||||
ShootingTypeBitReserve2 = 1 << ShootingTypeReserve2, //!< 予約
|
||||
ShootingTypeBitReserve3 = 1 << ShootingTypeReserve3, //!< 予約
|
||||
|
||||
ShootingTypeBitPhotoAll = ShootingTypeBitPhotoNormal
|
||||
| ShootingTypeBitPhotoFace
|
||||
| ShootingTypeBitPhotoEffect
|
||||
| ShootingTypeBitPhotoDayDream
|
||||
| ShootingTypeBitPhotoToy
|
||||
| ShootingTypeBitPhotoAfterimage
|
||||
| ShootingTypeBitPhotoFramelate
|
||||
| ShootingTypeBitPhotoQuestion
|
||||
| ShootingTypeBitPhotoManual,
|
||||
|
||||
ShootingTypeBitMovieAll = ShootingTypeBitMovieNormal
|
||||
| ShootingTypeBitMovieFramelate
|
||||
| ShootingTypeBitMovieManual,
|
||||
|
||||
ShootingTypeBitAll = ShootingTypeBitPhotoAll
|
||||
| ShootingTypeBitMovieAll
|
||||
};
|
||||
|
||||
//! 写真特徴タイプ
|
||||
enum DistinctionType {
|
||||
DistinctionTypeNone = 0, // 0 特徴なし
|
||||
|
||||
DistinctionTypeMale, // 1 男性が含まれている
|
||||
DistinctionTypeFemale, // 2 女性が含まれている
|
||||
DistinctionTypeStranger, // 3 変な人が含まれている
|
||||
DistinctionTypeMii, // 4 Miiが含まれている
|
||||
DistinctionTypeDecorationShooting, // 5 デコレーション撮影
|
||||
DistinctionTypeManualShooting, // 6 こだわり撮影
|
||||
DistinctionTypeScreenShot, // 7 ゲーム画面
|
||||
|
||||
DistinctionTypeNum,
|
||||
|
||||
DistinctionTypeReserved8 = DistinctionTypeNum, // 8
|
||||
DistinctionTypeReserved9, // 9
|
||||
DistinctionTypeReserved10, // 10
|
||||
DistinctionTypeReserved11, // 11
|
||||
DistinctionTypeReserved12, // 12
|
||||
DistinctionTypeReserved13, // 13
|
||||
DistinctionTypeReserved14, // 14
|
||||
DistinctionTypeReserved15, // 15 ここまでが限界
|
||||
|
||||
DistinctionTypeMax
|
||||
};
|
||||
|
||||
//! 写真特徴タイプのビットフラグ
|
||||
enum DistinctionTypeBit {
|
||||
DistinctionTypeBitNone = 0,
|
||||
|
||||
DistinctionTypeBitMale = 1 << DistinctionTypeMale, // 男性が含まれている
|
||||
DistinctionTypeBitFemale = 1 << DistinctionTypeFemale, // 女性が含まれている
|
||||
DistinctionTypeBitStranger = 1 << DistinctionTypeStranger, // 変な人が含まれている
|
||||
DistinctionTypeBitMii = 1 << DistinctionTypeMii, // Miiが含まれている
|
||||
|
||||
DistinctionTypeBitDecorationShooting = 1 << DistinctionTypeDecorationShooting, // デコレーション撮影
|
||||
DistinctionTypeBitManualShooting = 1 << DistinctionTypeManualShooting, // こだわり撮影
|
||||
DistinctionTypeBitScreenShot = 1 << DistinctionTypeScreenShot, // ゲーム画面
|
||||
|
||||
// 人物が含まれている
|
||||
DistinctionTypeBitPerson = DistinctionTypeBitMale
|
||||
| DistinctionTypeBitFemale
|
||||
| DistinctionTypeBitStranger,
|
||||
|
||||
DistinctionTypeBitAll = DistinctionTypeBitPerson
|
||||
| DistinctionTypeBitMii
|
||||
| DistinctionTypeBitDecorationShooting
|
||||
| DistinctionTypeBitManualShooting
|
||||
| DistinctionTypeBitScreenShot
|
||||
};
|
||||
|
||||
|
||||
//! 保存過程タイプ列挙型
|
||||
enum SaveProcessType
|
||||
{
|
||||
SaveProcessTypeUnknown = 0, // 0 不明
|
||||
|
||||
SaveProcessTypeSystemApp, // 1 システムアプリケーション(3DSカメラ)
|
||||
SaveProcessTypeMenu, // 2 システムアプレット
|
||||
SaveProcessTypeApplet, // 3 ライブラリアプレット
|
||||
SaveProcessTypeLibrary, // 4 ImageDbライブラリ
|
||||
SaveProcessTypeScreenshot, // 5 スクリーンショットAPI
|
||||
SaveProcessTypeOther, // 6 その他
|
||||
|
||||
SaveProcessTypeNum,
|
||||
|
||||
SaveProcessTypeReserved7 = SaveProcessTypeNum, // 7
|
||||
SaveProcessTypeReserved8, // 8
|
||||
SaveProcessTypeReserved9, // 9
|
||||
SaveProcessTypeReserved10, // 10
|
||||
SaveProcessTypeReserved11, // 11
|
||||
SaveProcessTypeReserved12, // 12
|
||||
SaveProcessTypeReserved13, // 13
|
||||
SaveProcessTypeReserved14, // 14
|
||||
SaveProcessTypeReserved15, // 15 ここまでが限界
|
||||
|
||||
SaveProcessTypeMax
|
||||
};
|
||||
|
||||
//! 保存過程タイプのビットフラグ列挙型
|
||||
enum SaveProcessTypeBit
|
||||
{
|
||||
SaveProcessTypeBitUnknown = 1 << SaveProcessTypeUnknown,
|
||||
|
||||
SaveProcessTypeBitSystemApp = 1 << SaveProcessTypeSystemApp, // システムアプリケーション(3DSカメラ)
|
||||
SaveProcessTypeBitMenu = 1 << SaveProcessTypeMenu, // システムアプレット
|
||||
SaveProcessTypeBitApplet = 1 << SaveProcessTypeApplet, // ライブラリアプレット
|
||||
SaveProcessTypeBitLibrary = 1 << SaveProcessTypeLibrary, // ImageDbライブラリ
|
||||
SaveProcessTypeBitScreenshot = 1 << SaveProcessTypeScreenshot, // スクリーンショットAPI
|
||||
SaveProcessTypeBitOther = 1 << SaveProcessTypeOther,
|
||||
|
||||
SaveProcessTypeBitAll = SaveProcessTypeBitUnknown
|
||||
| SaveProcessTypeBitSystemApp
|
||||
| SaveProcessTypeBitMenu
|
||||
| SaveProcessTypeBitApplet
|
||||
| SaveProcessTypeBitLibrary
|
||||
| SaveProcessTypeBitScreenshot
|
||||
| SaveProcessTypeBitOther
|
||||
};
|
||||
|
||||
|
||||
//! 本体IDタイプ列挙型
|
||||
enum BodyIdType
|
||||
{
|
||||
BodyIdTypeShot = 0, // 0 撮影した本体ID
|
||||
BodyIdTypeSend, // 1 送信した本体ID
|
||||
BodyIdTypeReceive, // 2 受信した本体ID
|
||||
BodyIdTypeEditor, // 3 最後に編集した本体ID
|
||||
|
||||
BodyIdTypeNum,
|
||||
BodyIdTypeMax = BodyIdTypeNum
|
||||
};
|
||||
|
||||
//! 本体IDタイプビット列挙型
|
||||
enum BodyIdTypeBit
|
||||
{
|
||||
BodyIdTypeBitNone = 0,
|
||||
|
||||
BodyIdTypeBitShot = 1 << BodyIdTypeShot, // 撮影した本体ID
|
||||
BodyIdTypeBitSend = 1 << BodyIdTypeSend, // 送信した本体ID
|
||||
BodyIdTypeBitReceive = 1 << BodyIdTypeReceive, // 受信した本体ID
|
||||
BodyIdTypeBitEditor = 1 << BodyIdTypeEditor, // 最後に編集した本体ID
|
||||
|
||||
BodyIdTypeBitAll = BodyIdTypeBitShot
|
||||
| BodyIdTypeBitSend
|
||||
| BodyIdTypeBitReceive
|
||||
| BodyIdTypeBitEditor
|
||||
};
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 取り扱い列挙型
|
||||
*---------------------------------------------------------------------------*/
|
||||
enum HandleType
|
||||
{
|
||||
HandleTypeReserved0 = 0, // 0 予約
|
||||
HandleTypeReserved1, // 1 予約
|
||||
HandleTypePermitDistribute, // 2 配布許可
|
||||
HandleTypeReserved3, // 3 予約
|
||||
HandleTypeAdjustablePicture, // 4 焦点調整可能
|
||||
|
||||
HandleTypeNum,
|
||||
|
||||
HandleTypeReserved5 = HandleTypeNum,// 5
|
||||
HandleTypeReserved6, // 6
|
||||
HandleTypeReserved7, // 7 ここまでが限界
|
||||
|
||||
HandleTypeMax
|
||||
};
|
||||
|
||||
//! 取り扱いビット列挙型
|
||||
enum HandleTypeBit
|
||||
{
|
||||
HandleTypeBitNone = 0,
|
||||
|
||||
HandleTypeBitReserved0 = 1 << HandleTypeReserved0, // 予約
|
||||
HandleTypeBitReserved1 = 1 << HandleTypeReserved1, // 予約
|
||||
HandleTypeBitPermitDistribute = 1 << HandleTypePermitDistribute, // 配布許可
|
||||
HandleTypeBitReserved3 = 1 << HandleTypeReserved3, // 予約
|
||||
HandleTypeBitAdjustablePicture = 1 << HandleTypeAdjustablePicture, // 焦点調整可能
|
||||
|
||||
HandleTypeBitAll = HandleTypeBitReserved0
|
||||
| HandleTypeBitReserved1
|
||||
| HandleTypeBitPermitDistribute
|
||||
| HandleTypeBitReserved3
|
||||
| HandleTypeBitAdjustablePicture
|
||||
};
|
||||
|
||||
|
||||
//! レガシー 署名の鍵タイプ(TWL-SDKのTCLKeyType列挙型準拠)
|
||||
enum LegacyKeyType {
|
||||
LegacyKeyTypeLauncher = 0, //!< ランチャー鍵
|
||||
LegacyKeyTypeApplication, //!< 一般鍵
|
||||
LegacyKeyTypeUnknown, //!< 不明鍵
|
||||
|
||||
LegacyKeyTypeNum
|
||||
};
|
||||
|
||||
//! レガシー 署名の鍵タイプのビットフラグ(TWL-SDKのTCLKeyType列挙型準拠)
|
||||
enum LegacyKeyTypeBit {
|
||||
LegacyKeyTypeBitLauncher = 1 << LegacyKeyTypeLauncher, //!< ランチャー鍵
|
||||
LegacyKeyTypeBitApplication = 1 << LegacyKeyTypeApplication, //!< 一般鍵
|
||||
LegacyKeyTypeBitUnknown = 1 << LegacyKeyTypeUnknown, //!< 不明鍵
|
||||
|
||||
LegacyKeyTypeBitKnownAll = LegacyKeyTypeBitLauncher
|
||||
| LegacyKeyTypeBitApplication,
|
||||
|
||||
LegacyKeyTypeBitAll = LegacyKeyTypeBitUnknown
|
||||
| LegacyKeyTypeBitKnownAll
|
||||
};
|
||||
|
||||
//! レガシー 画像タイプ(TWL-SDKのTCLImageType列挙型準拠)
|
||||
enum LegacyImageType {
|
||||
LegacyImageTypePicture = 0,
|
||||
LegacyImageTypeFrame,
|
||||
LegacyImageTypeComposite,
|
||||
LegacyImageTypeUnknown,
|
||||
|
||||
LegacyImageTypeNum
|
||||
};
|
||||
|
||||
|
||||
//! レガシー お気に入りタイプ(TWL-SDKのTCLFavoriteType列挙型準拠)
|
||||
enum LegacyFavoriteType {
|
||||
LegacyFavoriteTypeNone = 0,
|
||||
|
||||
LegacyFavoriteType1, //!< 星
|
||||
LegacyFavoriteTypeStar = LegacyFavoriteType1,
|
||||
|
||||
LegacyFavoriteType2, //!< クローバー
|
||||
LegacyFavoriteTypeClover = LegacyFavoriteType2,
|
||||
|
||||
LegacyFavoriteType3, //!< ハート
|
||||
LegacyFavoriteTypeHeart = LegacyFavoriteType3,
|
||||
|
||||
LegacyFavoriteTypeNum
|
||||
};
|
||||
|
||||
//! レガシー お気に入りタイプのビットフラグ(TWL-SDKのTCLFavoriteType列挙型準拠)
|
||||
enum LegacyFavoriteTypeBit {
|
||||
LegacyFavoriteTypeBitNone = 1 << LegacyFavoriteTypeNone,
|
||||
|
||||
LegacyFavoriteTypeBit1 = 1 << LegacyFavoriteType1, //!< 星
|
||||
LegacyFavoriteTypeBitStar = LegacyFavoriteTypeBit1,
|
||||
|
||||
LegacyFavoriteTypeBit2 = 1 << LegacyFavoriteType2, //!< クローバー
|
||||
LegacyFavoriteTypeBitClover = LegacyFavoriteTypeBit2,
|
||||
|
||||
LegacyFavoriteTypeBit3 = 1 << LegacyFavoriteType3, //!< ハート
|
||||
LegacyFavoriteTypeBitHeart = LegacyFavoriteTypeBit3,
|
||||
|
||||
// すべてのマーク
|
||||
LegacyFavoriteTypeBitMarkAll = LegacyFavoriteTypeBit1
|
||||
| LegacyFavoriteTypeBit2
|
||||
| LegacyFavoriteTypeBit3,
|
||||
|
||||
LegacyFavoriteTypeBitAll = LegacyFavoriteTypeBitNone
|
||||
| LegacyFavoriteTypeBitMarkAll
|
||||
};
|
||||
|
||||
|
||||
//! 妥当性状態
|
||||
enum ValidityState {
|
||||
ValidityStateUnknown = 0, // 不明
|
||||
ValidityStateValid, // 有効
|
||||
ValidityStateInvalid, // 無効
|
||||
|
||||
ValidityStateNum
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_TYPES_H_
|
||||
@ -0,0 +1,23 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbUtility.h
|
||||
|
||||
ƒ†<EFBFBD>[ƒeƒBƒŠƒeƒB
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_UTILITY_H_
|
||||
#define IMAGE_DB_UTILITY_H_
|
||||
|
||||
#include "ImageDbMiscUtility.h"
|
||||
#include "ImageDbPathUtility.h"
|
||||
#include "ImageDbFileUtility.h"
|
||||
#include "ImageDbImageUtility.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_UTILITY_H_
|
||||
@ -0,0 +1,220 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDbValidityStateTable.h
|
||||
|
||||
映像妥当性管理データ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_VALIDITY_STATE_TABLE_H_
|
||||
#define IMAGE_DB_VALIDITY_STATE_TABLE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像妥当性管理データのヘッダ構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct ValidityStateTableHeader
|
||||
{
|
||||
public:
|
||||
u16 nNumElements;
|
||||
u16 reserved;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] nExtAreaSize 拡張領域サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize(int nRecordNum);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief レコード数を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ return nNumElements; }
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像妥当性管理データのレコード構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
#pragma pack(push, 1)
|
||||
struct ValidityStateTableRecord
|
||||
{
|
||||
public:
|
||||
union {
|
||||
u8 nValidityStatus;
|
||||
struct {
|
||||
u8 nThumbnailValidityState : 2; // ValidityState列挙型 サムネイル画像の妥当性状態
|
||||
u8 nImageValidityState : 2; // ValidityState列挙型 本画像の妥当性状態
|
||||
u8 nReserved : 4;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイル画像の妥当性状態を取得/設定する
|
||||
@return 妥当性状態
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ValidityState GetThumbnailValidityState() const;
|
||||
void SetThumbnailValidityState(ValidityState eState);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 本画像の妥当性状態を取得/設定する
|
||||
@return 妥当性状態
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ValidityState GetImageValidityState() const;
|
||||
void SetImageValidityState(ValidityState eState);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種妥当性が有効かチェックする
|
||||
@return 有効ならtrue
|
||||
@details
|
||||
すべて有効ならtrueを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsStateValid() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 各種妥当性が無効かチェックする
|
||||
@return 無効ならtrue
|
||||
@details
|
||||
1つでも無効の場合はtrueを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsStateInvalid() const;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 映像妥当性管理データ
|
||||
@details
|
||||
このクラスは映像妥当性管理データの実体を外部から受け取って動作するアクセサです。
|
||||
新規で管理データを用意する場合は ComputeTableSize() 分の確保したメモリを
|
||||
SetInitialTableData() で設定します。
|
||||
ファイルから読み込んだりした既存のデータを使用する場合は、SetExistingTableData()
|
||||
で設定します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class ValidityStateTable
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
ValidityStateTable();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータサイズ求める
|
||||
@param[in] nRecordNum レコード数
|
||||
@param[in] nExtAreaSize 拡張領域のサイズ(バイト単位)
|
||||
@return サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static std::size_t ComputeTableSize(int nRecordNum);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータを取得する
|
||||
@return データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetTableData() const{ return m_pData; }
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのデータサイズを取得する
|
||||
@return サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetTableDataSize() const{ return m_nDataSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルデータを初期化して設定する
|
||||
@details
|
||||
指定のレコード数、拡張領域サイズがデータサイズを超えている場合はfalse
|
||||
を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetInitialTableData(void* pData, std::size_t nDataSize, int nRecordNum);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 既存の管理テーブルデータを設定する
|
||||
@details
|
||||
設定されたデータのヘッダ部を調査し、無効な場合はfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetExistingTableData(void* pData, std::size_t nDataSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
@details
|
||||
サイズ、識別子、CRCなどをチェックします。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Validate() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのヘッダ部を取得する
|
||||
@return ヘッダ部
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const ValidityStateTableHeader* GetHeader() const{
|
||||
NN_NULL_ASSERT(m_pData);
|
||||
return reinterpret_cast<const ValidityStateTableHeader*>(m_pData); }
|
||||
|
||||
ValidityStateTableHeader* GetHeader(){
|
||||
return const_cast<ValidityStateTableHeader*>(static_cast<const ValidityStateTable&>(*this).GetHeader()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのレコード数を取得する
|
||||
@return レコード数
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRecordNum() const{ return GetHeader()->GetRecordNum(); }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理テーブルのレコードを取得する
|
||||
@param[in] nIndex 取得するレコードのインデックス [0, GetRecordNum())
|
||||
@return レコード
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const ValidityStateTableRecord* GetRecord(int nIndex) const{
|
||||
NN_ASSERT(0 <= nIndex && nIndex < GetRecordNum());
|
||||
return &GetTopRecord()[nIndex]; }
|
||||
|
||||
ValidityStateTableRecord* GetRecord(int nIndex){
|
||||
return const_cast<ValidityStateTableRecord*>(static_cast<const ValidityStateTable&>(*this).GetRecord(nIndex)); }
|
||||
//@}
|
||||
|
||||
private:
|
||||
const ValidityStateTableRecord* GetTopRecord() const {
|
||||
return reinterpret_cast<const ValidityStateTableRecord*>(
|
||||
&reinterpret_cast<const u8*>(m_pData)[sizeof(ValidityStateTableHeader)]); }
|
||||
private:
|
||||
void* m_pData;
|
||||
std::size_t m_nDataSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_DB_VALIDITY_STATE_TABLE_H_
|
||||
903
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/JpegMpDecoder.h
Normal file
903
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/JpegMpDecoder.h
Normal file
@ -0,0 +1,903 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: JpegMpDecoder.h
|
||||
|
||||
JPEG/MPデコーダ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef JPEG_MP_DECODER_H_
|
||||
#define JPEG_MP_DECODER_H_
|
||||
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include <nn/fnd.h>
|
||||
#include <nn/jpeg.h>
|
||||
#include <nn/jpeg/ctr/jpeg_MpDecoderS.h>
|
||||
#include "SysMakerNote.h"
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbConst.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEG/MPベースデコードクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class JpegMpBaseDecoder
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
explicit JpegMpBaseDecoder(nn::jpeg::CTR::JpegMpDecoderS& rNnDecoder);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegMpBaseDecoder() = 0;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
EXIF関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした撮影日時情報を取得する
|
||||
@param[in] rDateTime 撮影日時
|
||||
@return デコードに成功していない場合はfalse
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetDateTime(nn::fnd::DateTime& rDateTime) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードしたユーザーメーカーノートを取得する
|
||||
@return ユーザーメーカーノート
|
||||
@details
|
||||
デコードに成功していない場合はヌルを返します。
|
||||
戻り値のアドレスは4バイトアラインになっていないことがあります。そのため
|
||||
浮動小数などの読みだしのアラインが決まっているデータなどを扱う場合は、
|
||||
アクセスに気をつけてください。
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetUserMakerNote() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードしたユーザーメーカーノートのサイズ取得する
|
||||
@return サイズ
|
||||
@details
|
||||
デコードに成功していない場合は0を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetUserMakerNoteSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードしたソフトウェア名を取得する
|
||||
@return ソフトウェア名
|
||||
@details
|
||||
デコードに成功していない場合はヌルを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
const char* GetSoftware() const;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
システムメーカーノート関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートを取得する
|
||||
@return システムメーカーノート
|
||||
@details
|
||||
システムメーカーノートと判断できない場合はヌルを返します。
|
||||
戻り値のアドレスは4バイトアラインになっていないことがあるため、void*型
|
||||
で返しています。アラインの揃っていない状態でSysMakerNote型にキャストす
|
||||
ると浮動小数関連の例外が発生するので気を付けてください。
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetSysMakerNote() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートを取得する
|
||||
@param[out] rSysNote 取得したシステムメーカーノート
|
||||
@return 取得できた場合はtrue
|
||||
@details
|
||||
システムメーカーノートと判断できない場合は失敗します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetSysMakerNote(SysMakerNote& rSysNote) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief フォーマット確認用コードを取得する
|
||||
@return フォーマット確認用コード
|
||||
@details
|
||||
システムメーカーノートが読めこめなかったり、知らないコードだった場合は
|
||||
ゼロを返します。
|
||||
アプリ側ではこの値がゼロかどうかで有効かどうかを判断してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSysMakerNoteCode() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのファイル作成日時を取得する
|
||||
@details
|
||||
システムメーカーノートが無効な場合はDateTimeSeconds::GetMinSeconds()を
|
||||
返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
DateTimeSeconds GetSysMakerNoteCreateSeconds() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのタイトルユニークIDを取得する
|
||||
@details
|
||||
システムメーカーノートが無効な場合は0を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSysMakerNoteTitleUniqueId() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの保存プロセスを取得する
|
||||
@details
|
||||
システムメーカーノートが無効な場合はSaveProcessTypeUnknownを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
SaveProcessType GetSysMakerNoteSaveProcessType() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの操作フラグを取得する
|
||||
@return HandleFlagBit列挙型の論理和
|
||||
@details
|
||||
システムメーカーノートが無効な場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
HandleTypeBit GetSysMakerNoteHandleFlag() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの本体IDが有効かチェックする
|
||||
@param[in] eType チェックする本体IDのタイプ
|
||||
@details
|
||||
システムメーカーノートが無効な場合はfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidSysMakerNoteId(BodyIdType eType) const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの本体IDを取得する
|
||||
@param[in] eType 取得する本体IDのタイプ
|
||||
@details
|
||||
システムメーカーノートが無効な場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSysMakerNoteId(BodyIdType eType) const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのMPファイル水平オフセットを取得する
|
||||
@details
|
||||
システムメーカーノートが無効な場合、または値が不正な場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
f32 GetSysMakerNoteMpOffsetH() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのお気に入り順を取得/設定する(レガシー)
|
||||
@details
|
||||
システムメーカーノートが無効な場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
s32 GetSysMakerNoteLegacyFavoriteOrder() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのお気に入りタイプを取得する(レガシー)
|
||||
@details
|
||||
システムメーカーノートが無効な場合はLegacyFavoriteTypeNoneを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
LegacyFavoriteType GetSysMakerNoteLegacyFavoriteType() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの画像タイプを取得する(レガシー)
|
||||
@details
|
||||
システムメーカーノートが無効な場合はLegacyImageTypeUnknownを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
LegacyImageType GetSysMakerNoteLegacyImageType() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの署名の鍵タイプを取得する(レガシー)
|
||||
@details
|
||||
システムメーカーノートが無効な場合はLegacyKeyTypeUnknownを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
LegacyKeyType GetSysMakerNoteLegacyKeyType() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのデフォルトフレーム状態を取得する(レガシー)
|
||||
@details
|
||||
システムメーカーノートが無効な場合はfalseを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsSysMakerNoteLegacyDefaultFrame() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの撮影タイプを取得する
|
||||
@details
|
||||
システムメーカーノートが無効な場合はShootingTypePhotoNormalを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
ShootingType GetSysMakerNoteShootingType() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの写真特徴フラグを取得する
|
||||
@details
|
||||
システムメーカーノートが無効な場合はDistinctionTypeBitNoneを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
DistinctionTypeBit GetSysMakerNoteDistinctionTypeBit() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 縮小デコードされる場合の縮小レベルとサイズを求める
|
||||
@param[in,out] rShrinkWidth 幅(ドット単位)
|
||||
@param[in,out] rShrinkHeight 高さ(ドット単位)
|
||||
@param[in] nLimitWidth 制限幅(ドット単位)
|
||||
@param[in] nLimitHeight 制限高さ
|
||||
@return 縮小レベル
|
||||
-----------------------------------------------------------------------*/
|
||||
static int ComputeShrinkLevel(
|
||||
int& rShrinkWidth, int& rShrinkHeight, int nLimitWidth, int nLimitHeight);
|
||||
|
||||
private:
|
||||
// コーデック
|
||||
nn::jpeg::CTR::JpegMpDecoderS& m_rNnDecoder;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEGデコードクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class JpegDecoder : public JpegMpBaseDecoder, private nn::util::NonCopyable<JpegDecoder>
|
||||
{
|
||||
public:
|
||||
// デフォルトの最小画像制限サイズ
|
||||
static const int c_nDefaultMinImageLimitWidth = Const::c_nMinStandardPictureWidth;
|
||||
static const int c_nDefaultMinImageLimitHeight = Const::c_nMinStandardPictureHeight;
|
||||
// デフォルトの最大画像制限サイズ
|
||||
static const int c_nDefaultMaxImageLimitWidth = Const::c_nMaxStandardPictureWidth;
|
||||
static const int c_nDefaultMaxImageLimitHeight = Const::c_nMaxStandardPictureHeight;
|
||||
|
||||
// デフォルトの最大自動画像縮小レベル
|
||||
static const int c_nDefaultMaxImageShrinkLevel = 2;
|
||||
// デフォルトの自動画像縮小機能の有効フラグ
|
||||
static const bool c_bDefaultEnableAutoImageShrinkFlag = true;
|
||||
|
||||
|
||||
// デフォルトの最小サムネイル画像制限サイズ
|
||||
static const int c_nDefaultMinThumbnailLimitWidth = Const::c_nMinStandardThumbnailWidth;
|
||||
static const int c_nDefaultMinThumbnailLimitHeight = Const::c_nMinStandardThumbnailHeight;
|
||||
// デフォルトの最大サムネイル画像制限サイズ
|
||||
static const int c_nDefaultMaxThumbnailLimitWidth = Const::c_nMaxStandardThumbnailWidth;
|
||||
static const int c_nDefaultMaxThumbnailLimitHeight = Const::c_nMaxStandardThumbnailHeight;
|
||||
|
||||
// デフォルトの最大自動サムネイル画像縮小レベル
|
||||
static const int c_nDefaultMaxThumbnailShrinkLevel = 2;
|
||||
// デフォルトの自動サムネイル画像縮小機能の有効フラグ
|
||||
static const bool c_bDefaultEnableAutoThumbnailShrinkFlag = true;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] pJpegData JPEGデータ
|
||||
@param[in] nJpegSize JPEGデータのサイズ
|
||||
@param[out] pRawData デコードした生データを格納するバッファ
|
||||
@param[in] nRawDataSize 生データを格納するバッファのサイズ
|
||||
@details
|
||||
pRawDataの指定を省略した場合は、内部で自動でメモリが確保されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
JpegDecoder(
|
||||
const void* pJpegData, std::size_t nJpegSize);
|
||||
JpegDecoder(
|
||||
const void* pJpegData, std::size_t nJpegSize,
|
||||
void* pRawData, std::size_t nRawDataSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegDecoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードする
|
||||
@param[in] eRawFormat デコードする生データのフォーマット
|
||||
@param[in] bThumbnail サムネイルデコードフラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool Decode(nn::jpeg::CTR::PixelFormat eRawFormat);
|
||||
bool Decode(nn::jpeg::CTR::PixelFormat eRawFormat, bool bThumbnail);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコード処理中止を要求する
|
||||
@note
|
||||
デコードを中止するためのメソッドです。
|
||||
スレッドでデコードを行っているときに、メインスレッドなどからデコードを
|
||||
中止させたい場合などに使用します。
|
||||
停止の要求は必ず成功するわけではないため、終了するまで何度も呼び出す必要
|
||||
があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void StopDecoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief Exifだけを展開する
|
||||
@param[in] bThumbnail サムネイルt展開フラグ
|
||||
@details
|
||||
この関数を呼び出すとGetWidth()やGetRealWidth()、GetShrinkLevel()などの
|
||||
情報も取得できます。SetMinLimitWidth()やSetMaxShrinkLevel()で設定した制
|
||||
限を超えていて、ExtractExif()自身はエラーを返すわけではないので気を付け
|
||||
てください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ExtractExif();
|
||||
bool ExtractExif(bool bThumbnail);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最小/最大画像制限サイズを取得/設定する
|
||||
@details
|
||||
デコードする画像がこのサイズよりも小さい、または大きい場合、展開バッファ
|
||||
が十分であっても失敗扱いになります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMinImageLimitWidth() const{ return m_nMinImageLimitWidth; }
|
||||
void SetMinImageLimitWidth(int nWidth){ m_nMinImageLimitWidth = nWidth; }
|
||||
int GetMinImageLimitHeight() const{ return m_nMinImageLimitHeight; }
|
||||
void SetMinImageLimitHeight(int nHeight){ m_nMinImageLimitHeight = nHeight; }
|
||||
|
||||
int GetMaxImageLimitWidth() const{ return m_nMaxImageLimitWidth; }
|
||||
void SetMaxImageLimitWidth(int nWidth){ m_nMaxImageLimitWidth = nWidth; }
|
||||
int GetMaxImageLimitHeight() const{ return m_nMaxImageLimitHeight; }
|
||||
void SetMaxImageLimitHeight(int nHeight){ m_nMaxImageLimitHeight = nHeight; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最小/最大サムネイル画像制限サイズを取得/設定する
|
||||
@details
|
||||
デコードする画像がこのサイズよりも小さい、または大きい場合、展開バッファ
|
||||
が十分であっても失敗扱いになります。
|
||||
Min側のサイズは自動画像縮小を行わないオリジナルのサイズでの比較で、Max側の
|
||||
サイズは自動画像縮小を行ったサイズでの比較となります。
|
||||
そのためMaxより大きな画像になることはありませんが、Minより小さい画像にな
|
||||
ることはあります。
|
||||
またMin < Maxとも限りません。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMinThumbnailLimitWidth() const{ return m_nMinThumbnailLimitWidth; }
|
||||
void SetMinThumbnailLimitWidth(int nWidth){ m_nMinThumbnailLimitWidth = nWidth; }
|
||||
int GetMinThumbnailLimitHeight() const{ return m_nMinThumbnailLimitHeight; }
|
||||
void SetMinThumbnailLimitHeight(int nHeight){ m_nMinThumbnailLimitHeight = nHeight; }
|
||||
|
||||
int GetMaxThumbnailLimitWidth() const{ return m_nMaxThumbnailLimitWidth; }
|
||||
void SetMaxThumbnailLimitWidth(int nWidth){ m_nMaxThumbnailLimitWidth = nWidth; }
|
||||
int GetMaxThumbnailLimitHeight() const{ return m_nMaxThumbnailLimitHeight; }
|
||||
void SetMaxThumbnailLimitHeight(int nHeight){ m_nMaxThumbnailLimitHeight = nHeight; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 出力バッファの幅を取得/設定する
|
||||
@details
|
||||
この幅はデコードのバッファの横幅を指定するもので、指定することで例えば
|
||||
64×64の画像を256×256のバッファの左上に展開するといったことが可能にな
|
||||
ります。この値がデコード画像幅よりも小さい場合は、ビッチリと詰まった
|
||||
状態で画像が展開されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetOutputBufferWidth() const{ return m_nOutputBufferWidth; }
|
||||
void SetOutputBufferWidth(int nWidth){ m_nOutputBufferWidth = nWidth; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動画像縮小の最大縮小レベルを取得/設定する
|
||||
@details
|
||||
縮小レベルは0=等倍、1=1/2、2=1/4となります。
|
||||
指定できる範囲は[0,4]となります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMaxImageShrinkLevel() const{ return m_nMaxImageShrinkLevel; }
|
||||
void SetMaxImageShrinkLevel(int nLevel){ NN_ASSERT(0 <= nLevel && nLevel <= 4); m_nMaxImageShrinkLevel = nLevel; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動サムネイル画像縮小の最大縮小レベルを取得/設定する
|
||||
@details
|
||||
縮小レベルは0=等倍、1=1/2、2=1/4となります。
|
||||
指定できる範囲は[0,4]となります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMaxThumbnailShrinkLevel() const{ return m_nMaxThumbnailShrinkLevel; }
|
||||
void SetMaxThumbnailShrinkLevel(int nLevel){ NN_ASSERT(0 <= nLevel && nLevel <= 4); m_nMaxThumbnailShrinkLevel = nLevel; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動画像縮小機能の有効フラグを取得/設定する
|
||||
@details
|
||||
通常はGetMaxImageLimitWidth()、GetMaxImageLimitHeight()より大きな画像は
|
||||
デコードに失敗しますが、この機能を有効にすると1/2、1/4、1/8・・・といっ
|
||||
た単位で 制限サイズに収まるまで縮小します。
|
||||
縮小の限度は1/(1<<GetMaxImageShrinkLevel())までです。
|
||||
縮小した場合はGetWidth()やGetHeight()は縮小後のサイズとなります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetEnableAutoImageShrinkFlag() const{ return m_bEnableAutoImageShrinkFlag; }
|
||||
void SetEnableAutoImageShrinkFlag(bool bEnable){ m_bEnableAutoImageShrinkFlag = bEnable; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動無ネイル画像縮小機能の有効フラグを取得/設定する
|
||||
@details
|
||||
通常はGetMaxThumbnailLimitWidth()、GetMaxThumbnailLimitHeight()より大きな画像は
|
||||
デコードに失敗しますが、この機能を有効にすると1/2、1/4、1/8・・・といっ
|
||||
た単位で 制限サイズに収まるまで縮小します。
|
||||
縮小の限度は1/(1<<GetMaxThumbnailShrinkLevel())までです。
|
||||
縮小した場合はGetWidth()やGetHeight()は縮小後のサイズとなります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetEnableAutoThumbnailShrinkFlag() const{ return m_bEnableAutoThumbnailShrinkFlag; }
|
||||
void SetEnableAutoThumbnailShrinkFlag(bool bEnable){ m_bEnableAutoThumbnailShrinkFlag = bEnable; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした生データを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetRawData() const{ return m_pRawData; }
|
||||
void* GetRawData(){
|
||||
return const_cast<void*>(static_cast<const JpegDecoder&>(*this).GetRawData()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした生データのサイズを取得する
|
||||
@return データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetRawSize() const{ return m_nRawSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした画像の幅と高さを取得する
|
||||
@return 画像の幅
|
||||
@details
|
||||
自動画像縮小機能により縮小された場合は縮小後のサイズを返します。
|
||||
正確にはGetRealWidth(), GetRealHeight()をGetShrinkLevel()で縮小したサイ
|
||||
ズとなります。
|
||||
デコードに成功していない場合は0を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした画像の本当の幅と高さを取得する
|
||||
@return 画像の幅
|
||||
@details
|
||||
自動画像縮小機能で縮小されても本来のサイズを返します。
|
||||
デコードに成功していない場合は0を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetRealWidth() const;
|
||||
int GetRealHeight() const;
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードしたときの自動画像縮レベルを取得する
|
||||
@return 縮小レベル[0,4]
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetShrinkLevel() const{ return m_nShrinkedLevel; }
|
||||
|
||||
private:
|
||||
int GetMinLimitWidth(bool bThumbnail) const{ return bThumbnail ? GetMinThumbnailLimitWidth() : GetMinImageLimitWidth(); }
|
||||
int GetMinLimitHeight(bool bThumbnail) const{ return bThumbnail ? GetMinThumbnailLimitHeight() : GetMinImageLimitHeight(); }
|
||||
int GetMaxLimitWidth(bool bThumbnail) const{ return bThumbnail ? GetMaxThumbnailLimitWidth() : GetMaxImageLimitWidth(); }
|
||||
int GetMaxLimitHeight(bool bThumbnail) const{ return bThumbnail ? GetMaxThumbnailLimitHeight() : GetMaxImageLimitHeight(); }
|
||||
|
||||
int GetMaxShrinkLevel(bool bThumbnail) const{ return bThumbnail ? GetMaxThumbnailShrinkLevel() : GetMaxImageShrinkLevel(); }
|
||||
bool GetEnableAutoShrinkFlag(bool bThumbnail) const{ return bThumbnail ? GetEnableAutoThumbnailShrinkFlag() : GetEnableAutoImageShrinkFlag(); }
|
||||
|
||||
private:
|
||||
// コーデック
|
||||
nn::jpeg::CTR::JpegMpDecoderS m_NnDecoder;
|
||||
void* m_pDecoderBuf;
|
||||
|
||||
// 変換前のデータ
|
||||
const void* m_pJpegData;
|
||||
std::size_t m_pJpegSize;
|
||||
|
||||
// 変換情報
|
||||
int m_nMinImageLimitWidth;
|
||||
int m_nMinImageLimitHeight;
|
||||
int m_nMaxImageLimitWidth;
|
||||
int m_nMaxImageLimitHeight;
|
||||
int m_nMinThumbnailLimitWidth;
|
||||
int m_nMinThumbnailLimitHeight;
|
||||
int m_nMaxThumbnailLimitWidth;
|
||||
int m_nMaxThumbnailLimitHeight;
|
||||
int m_nOutputBufferWidth;
|
||||
int m_nMaxImageShrinkLevel;
|
||||
int m_nMaxThumbnailShrinkLevel;
|
||||
bool m_bEnableAutoImageShrinkFlag;
|
||||
bool m_bEnableAutoThumbnailShrinkFlag;
|
||||
|
||||
// 変換後のデータ
|
||||
bool m_bFreeRawData;
|
||||
u8* m_pRawData;
|
||||
std::size_t m_nRawDataSize; // m_pRawDataのバッファサイズ
|
||||
std::size_t m_nRawSize; // m_pRawDataに格納した生データサイズ
|
||||
nn::jpeg::CTR::PixelFormat m_eRawFormat;
|
||||
int m_nShrinkedLevel;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief MPデコードクラス
|
||||
@note
|
||||
MPデータを生データに変換します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class MpDecoder : public JpegMpBaseDecoder, private nn::util::NonCopyable<MpDecoder>
|
||||
{
|
||||
public:
|
||||
// デフォルトの最小画像制限サイズ
|
||||
static const int c_nDefaultMinImageLimitWidth = Const::c_nMinStandardPictureWidth;
|
||||
static const int c_nDefaultMinImageLimitHeight = Const::c_nMinStandardPictureHeight;
|
||||
// デフォルトの最大画像制限サイズ
|
||||
static const int c_nDefaultMaxImageLimitWidth = Const::c_nMaxStandardPictureWidth;
|
||||
static const int c_nDefaultMaxImageLimitHeight = Const::c_nMaxStandardPictureHeight;
|
||||
|
||||
// デフォルトの最大自動画像縮小レベル
|
||||
static const int c_nDefaultMaxImageShrinkLevel = 2;
|
||||
// デフォルトの自動画像縮小機能の有効フラグ
|
||||
static const bool c_bDefaultEnableAutoImageShrinkFlag = true;
|
||||
|
||||
|
||||
// デフォルトの最小サムネイル画像制限サイズ
|
||||
static const int c_nDefaultMinThumbnailLimitWidth = Const::c_nMinStandardThumbnailWidth;
|
||||
static const int c_nDefaultMinThumbnailLimitHeight = Const::c_nMinStandardThumbnailHeight;
|
||||
// デフォルトの最大サムネイル画像制限サイズ
|
||||
static const int c_nDefaultMaxThumbnailLimitWidth = Const::c_nMaxStandardThumbnailWidth;
|
||||
static const int c_nDefaultMaxThumbnailLimitHeight = Const::c_nMaxStandardThumbnailHeight;
|
||||
|
||||
// デフォルトの最大自動サムネイル画像縮小レベル
|
||||
static const int c_nDefaultMaxThumbnailShrinkLevel = 2;
|
||||
// デフォルトの自動サムネイル画像縮小機能の有効フラグ
|
||||
static const bool c_bDefaultEnableAutoThumbnailShrinkFlag = true;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] pMpData MPデータ
|
||||
@param[in] nMpSize MPデータのサイズ
|
||||
@param[out] pRawDataL 左目側のデコードした生データを格納するバッファ(ヌル可)
|
||||
@param[out] pRawDataR 右目側のデコードした生データを格納するバッファ(ヌル可)
|
||||
@param[in] nRawDataSize 生データを格納するバッファのサイズ
|
||||
@details
|
||||
pRawDataL、pRawDataRの指定を省略した場合は、内部で自動でメモリが確保されます。
|
||||
nRawDataSizeはpRawDataLかpRawDataRの少ない方のサイズを指定してください。
|
||||
本画像をデコードする場合、pRawDataLまたはpRawDataRにヌルを指定することで
|
||||
片方だけの画像を取得することができます。
|
||||
サムネイルをデコードする場合はpRawDataLのデータは必須です。pRawDataRの
|
||||
指定があればpRawDataLの画像がpRawDataRにコピーされます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
MpDecoder(
|
||||
const void* pMpData, std::size_t nMpSize);
|
||||
MpDecoder(
|
||||
const void* pMpData, std::size_t nMpSize,
|
||||
void* pRawDataL, void* pRawDataR, std::size_t nRawDataSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~MpDecoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードする
|
||||
@param[in] eRawFormat デコードする生データのフォーマット
|
||||
@param[in] bThumbnail サムネイルデコードフラグ
|
||||
@note
|
||||
サムネイル画像をデコードした場合は、左目側の画像にのみデータが格納されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool Decode(nn::jpeg::CTR::PixelFormat eRawFormat);
|
||||
bool Decode(nn::jpeg::CTR::PixelFormat eRawFormat, bool bThumbnail);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコード処理中止を要求する
|
||||
@note
|
||||
デコードを中止するためのメソッドです。
|
||||
スレッドでデコードを行っているときに、メインスレッドなどからデコードを
|
||||
中止させたい場合などに使用します。
|
||||
停止の要求は必ず成功するわけではないため、終了するまで何度も呼び出す必要
|
||||
があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void StopDecoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief Exifだけを展開する
|
||||
@param[in] bThumbnail サムネイルt展開フラグ
|
||||
@details
|
||||
この関数を呼び出すとGetWidth()やGetRealWidth()、GetShrinkLevel()などの
|
||||
情報も取得できます。SetMinLimitWidth()やSetMaxShrinkLevel()で設定した制
|
||||
限を超えていて、ExtractExif()自身はエラーを返すわけではないので気を付け
|
||||
てください。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ExtractExif();
|
||||
bool ExtractExif(bool bThumbnail);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最小/最大画像制限サイズを取得/設定する
|
||||
@details
|
||||
デコードする画像がこのサイズよりも小さい、または大きい場合、展開バッファ
|
||||
が十分であっても失敗扱いになります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMinImageLimitWidth() const{ return m_nMinImageLimitWidth; }
|
||||
void SetMinImageLimitWidth(int nWidth){ m_nMinImageLimitWidth = nWidth; }
|
||||
int GetMinImageLimitHeight() const{ return m_nMinImageLimitHeight; }
|
||||
void SetMinImageLimitHeight(int nHeight){ m_nMinImageLimitHeight = nHeight; }
|
||||
|
||||
int GetMaxImageLimitWidth() const{ return m_nMaxImageLimitWidth; }
|
||||
void SetMaxImageLimitWidth(int nWidth){ m_nMaxImageLimitWidth = nWidth; }
|
||||
int GetMaxImageLimitHeight() const{ return m_nMaxImageLimitHeight; }
|
||||
void SetMaxImageLimitHeight(int nHeight){ m_nMaxImageLimitHeight = nHeight; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最小/最大サムネイル画像制限サイズを取得/設定する
|
||||
@details
|
||||
デコードする画像がこのサイズよりも小さい、または大きい場合、展開バッファ
|
||||
が十分であっても失敗扱いになります。
|
||||
Min側のサイズは自動画像縮小を行わないオリジナルのサイズでの比較で、Max側の
|
||||
サイズは自動画像縮小を行ったサイズでの比較となります。
|
||||
そのためMaxより大きな画像になることはありませんが、Minより小さい画像にな
|
||||
ることはあります。
|
||||
またMin < Maxとも限りません。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMinThumbnailLimitWidth() const{ return m_nMinThumbnailLimitWidth; }
|
||||
void SetMinThumbnailLimitWidth(int nWidth){ m_nMinThumbnailLimitWidth = nWidth; }
|
||||
int GetMinThumbnailLimitHeight() const{ return m_nMinThumbnailLimitHeight; }
|
||||
void SetMinThumbnailLimitHeight(int nHeight){ m_nMinThumbnailLimitHeight = nHeight; }
|
||||
|
||||
int GetMaxThumbnailLimitWidth() const{ return m_nMaxThumbnailLimitWidth; }
|
||||
void SetMaxThumbnailLimitWidth(int nWidth){ m_nMaxThumbnailLimitWidth = nWidth; }
|
||||
int GetMaxThumbnailLimitHeight() const{ return m_nMaxThumbnailLimitHeight; }
|
||||
void SetMaxThumbnailLimitHeight(int nHeight){ m_nMaxThumbnailLimitHeight = nHeight; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 出力バッファの幅を取得/設定する
|
||||
@details
|
||||
この幅はデコードのバッファの横幅を指定するもので、指定することで例えば
|
||||
64×64の画像を256×256のバッファの左上に展開するといったことが可能にな
|
||||
ります。この値がデコード画像幅よりも小さい場合は、ビッチリと詰まった
|
||||
状態で画像が展開されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetOutputBufferWidth() const{ return m_nOutputBufferWidth; }
|
||||
void SetOutputBufferWidth(int nWidth){ m_nOutputBufferWidth = nWidth; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動画像縮小の最大縮小レベルを取得/設定する
|
||||
@details
|
||||
縮小レベルは0=等倍、1=1/2、2=1/4となります。
|
||||
指定できる範囲は[0,4]となります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMaxImageShrinkLevel() const{ return m_nMaxImageShrinkLevel; }
|
||||
void SetMaxImageShrinkLevel(int nLevel){ NN_ASSERT(0 <= nLevel && nLevel <= 4); m_nMaxImageShrinkLevel = nLevel; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動サムネイル画像縮小の最大縮小レベルを取得/設定する
|
||||
@details
|
||||
縮小レベルは0=等倍、1=1/2、2=1/4となります。
|
||||
指定できる範囲は[0,4]となります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetMaxThumbnailShrinkLevel() const{ return m_nMaxThumbnailShrinkLevel; }
|
||||
void SetMaxThumbnailShrinkLevel(int nLevel){ NN_ASSERT(0 <= nLevel && nLevel <= 4); m_nMaxThumbnailShrinkLevel = nLevel; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動画像縮小機能の有効フラグを取得/設定する
|
||||
@details
|
||||
通常はGetMaxImageLimitWidth()、GetMaxImageLimitHeight()より大きな画像は
|
||||
デコードに失敗しますが、この機能を有効にすると1/2、1/4、1/8・・・といっ
|
||||
た単位で 制限サイズに収まるまで縮小します。
|
||||
縮小の限度は1/(1<<GetMaxImageShrinkLevel())までです。
|
||||
縮小した場合はGetWidth()やGetHeight()は縮小後のサイズとなります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetEnableAutoImageShrinkFlag() const{ return m_bEnableAutoImageShrinkFlag; }
|
||||
void SetEnableAutoImageShrinkFlag(bool bEnable){ m_bEnableAutoImageShrinkFlag = bEnable; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 自動無ネイル画像縮小機能の有効フラグを取得/設定する
|
||||
@details
|
||||
通常はGetMaxThumbnailLimitWidth()、GetMaxThumbnailLimitHeight()より大きな画像は
|
||||
デコードに失敗しますが、この機能を有効にすると1/2、1/4、1/8・・・といっ
|
||||
た単位で 制限サイズに収まるまで縮小します。
|
||||
縮小の限度は1/(1<<GetMaxThumbnailShrinkLevel())までです。
|
||||
縮小した場合はGetWidth()やGetHeight()は縮小後のサイズとなります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetEnableAutoThumbnailShrinkFlag() const{ return m_bEnableAutoThumbnailShrinkFlag; }
|
||||
void SetEnableAutoThumbnailShrinkFlag(bool bEnable){ m_bEnableAutoThumbnailShrinkFlag = bEnable; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした左目側の生データを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetRawDataL() const { return m_pRawDataL; }
|
||||
void* GetRawDataL(){
|
||||
return const_cast<void*>(static_cast<const MpDecoder&>(*this).GetRawDataL()); }
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした右目側の生データを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetRawDataR() const { return m_pRawDataR; }
|
||||
void* GetRawDataR(){
|
||||
return const_cast<void*>(static_cast<const MpDecoder&>(*this).GetRawDataR()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした生データのサイズを取得する
|
||||
@return データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetRawSize() const { return m_nRawSize; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした画像の幅と高さを取得する
|
||||
@return 画像の幅
|
||||
@details
|
||||
自動画像縮小機能により縮小された場合は縮小後のサイズを返します。
|
||||
正確にはGetRealWidth(), GetRealHeight()をGetShrinkLevel()で縮小したサイ
|
||||
ズとなります。
|
||||
デコードに成功していない場合は0を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした画像の本当の幅と高さを取得する
|
||||
@return 画像の幅
|
||||
@details
|
||||
自動画像縮小機能で縮小されても本来のサイズを返します。
|
||||
デコードに成功していない場合は0を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetRealWidth() const;
|
||||
int GetRealHeight() const;
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードしたときの自動画像縮レベルを取得する
|
||||
@return 縮小レベル[0,4]
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetShrinkLevel() const{ return m_nShrinkedLevel; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPからJPEGを取り出す
|
||||
@param[out] pJpegData 取り出したJPEGを格納するバッファ
|
||||
@param[in] nJpegDataSize pJpegDataのバッファサイズ
|
||||
@param[out] rJpegSize pJpegDataに格納したJPEGのサイズ
|
||||
@return 取り出しに施行した場合はfalseを返す
|
||||
@note
|
||||
JPEGを格納するバッファが足りない場合はfalseを返します。
|
||||
取り出したJPEGのExifは、元のMPのExifに可能な限り揃えています。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool ExtractJpegL(void* pJpegData, std::size_t nJpegDataSize, std::size_t& rJpegSize);
|
||||
bool ExtractJpegR(void* pJpegData, std::size_t nJpegDataSize, std::size_t& rJpegSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPからJPEGを取り出すのに必要なバッファサイズを求める
|
||||
@return バッファサイズ
|
||||
@note
|
||||
この関数で取得したサイズは、ExtractJpeg()で必要なバッファサイズを必ず満
|
||||
たします。
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t ComputeExtractJpegSize();
|
||||
|
||||
private:
|
||||
static const int c_nMaxShrinkLevel = 2;
|
||||
|
||||
private:
|
||||
int GetMinLimitWidth(bool bThumbnail) const{ return bThumbnail ? GetMinThumbnailLimitWidth() : GetMinImageLimitWidth(); }
|
||||
int GetMinLimitHeight(bool bThumbnail) const{ return bThumbnail ? GetMinThumbnailLimitHeight() : GetMinImageLimitHeight(); }
|
||||
int GetMaxLimitWidth(bool bThumbnail) const{ return bThumbnail ? GetMaxThumbnailLimitWidth() : GetMaxImageLimitWidth(); }
|
||||
int GetMaxLimitHeight(bool bThumbnail) const{ return bThumbnail ? GetMaxThumbnailLimitHeight() : GetMaxImageLimitHeight(); }
|
||||
|
||||
int GetMaxShrinkLevel(bool bThumbnail) const{ return bThumbnail ? GetMaxThumbnailShrinkLevel() : GetMaxImageShrinkLevel(); }
|
||||
bool GetEnableAutoShrinkFlag(bool bThumbnail) const{ return bThumbnail ? GetEnableAutoThumbnailShrinkFlag() : GetEnableAutoImageShrinkFlag(); }
|
||||
|
||||
bool ExtractJpeg(
|
||||
int nIndex, void* pJpegData, std::size_t nJpegDataSize, std::size_t& rJpegSize);
|
||||
|
||||
static std::size_t StartMpDecoderLR(
|
||||
nn::jpeg::CTR::JpegMpDecoderS& rNnDec,
|
||||
void* pDstL, void* pDstR, std::size_t nDstSize,
|
||||
const void* pSrc, std::size_t nSrcSize,
|
||||
int nMaxWidth, int nMaxHeight, int nOutputBufferWidth,
|
||||
nn::jpeg::CTR::PixelFormat eDstPixelFormat, int nShrinkLevel);
|
||||
|
||||
static bool GetMpEntryIndexLR(
|
||||
nn::jpeg::CTR::JpegMpDecoderS& rNnDec,
|
||||
int& rIndexL, int& rIndexR,
|
||||
const nn::jpeg::CTR::MpIndex& rMpIndex,
|
||||
const void* pSrc, std::size_t nSrcSize);
|
||||
|
||||
static bool GetMpRegionsToBuildJpegData(
|
||||
nn::jpeg::CTR::JpegMpDecoderS& rNnDec,
|
||||
nn::jpeg::CTR::MpRegionsToBuildJpegData& rBuildJpegData,
|
||||
const nn::jpeg::CTR::MpEntry& rMpEntry,
|
||||
const void* pSrc, std::size_t nSrcSize);
|
||||
|
||||
static bool GetMpIndex(
|
||||
nn::jpeg::CTR::JpegMpDecoderS& rNnDec, nn::jpeg::CTR::MpIndex& rMpIndex,
|
||||
const void* pSrc, std::size_t nSrcSize);
|
||||
|
||||
static bool GetMpImageAddrByIndex(
|
||||
nn::jpeg::CTR::JpegMpDecoderS& rNnDec,
|
||||
const void*& rAddr, std::size_t& rSize,
|
||||
const void* pSrc, std::size_t nSrcSize,
|
||||
const nn::jpeg::CTR::MpIndex& rMpIndex, int nIndex);
|
||||
|
||||
private:
|
||||
// コーデック
|
||||
nn::jpeg::CTR::JpegMpDecoderS m_NnDecoder;
|
||||
void* m_pDecoderBuf;
|
||||
|
||||
// 変換前のデータ
|
||||
const void* m_pMpData;
|
||||
std::size_t m_nMpSize;
|
||||
|
||||
// 変換情報
|
||||
int m_nMinImageLimitWidth;
|
||||
int m_nMinImageLimitHeight;
|
||||
int m_nMaxImageLimitWidth;
|
||||
int m_nMaxImageLimitHeight;
|
||||
int m_nMinThumbnailLimitWidth;
|
||||
int m_nMinThumbnailLimitHeight;
|
||||
int m_nMaxThumbnailLimitWidth;
|
||||
int m_nMaxThumbnailLimitHeight;
|
||||
int m_nOutputBufferWidth;
|
||||
int m_nMaxImageShrinkLevel;
|
||||
int m_nMaxThumbnailShrinkLevel;
|
||||
bool m_bEnableAutoImageShrinkFlag;
|
||||
bool m_bEnableAutoThumbnailShrinkFlag;
|
||||
|
||||
// 変換後のデータ
|
||||
bool m_bFreeRawData;
|
||||
u8* m_pRawDataL;
|
||||
u8* m_pRawDataR;
|
||||
std::size_t m_nRawDataSize; // m_pRawDataのバッファサイズ
|
||||
std::size_t m_nRawSize; // m_pRawDataに格納した生データサイズ
|
||||
nn::jpeg::CTR::PixelFormat m_eRawFormat;
|
||||
int m_nShrinkedLevel;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // JPEG_MP_DECODER_H_
|
||||
515
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/JpegMpEncoder.h
Normal file
515
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/JpegMpEncoder.h
Normal file
@ -0,0 +1,515 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: JpegMpEncoder.h
|
||||
|
||||
JPEG/MPエンコーダ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef JPEG_MP_ENCODER_H_
|
||||
#define JPEG_MP_ENCODER_H_
|
||||
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include <nn/fnd.h>
|
||||
#include <nn/jpeg.h>
|
||||
#include "SysMakerNote.h"
|
||||
#include "ImageDbTypes.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEG/MPベースエンコードクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class JpegMpBaseEncoder
|
||||
{
|
||||
public:
|
||||
// デフォルトのJPEGフォーマット
|
||||
static const nn::jpeg::CTR::PixelSampling c_eDefaultFormat = nn::jpeg::CTR::PIXEL_SAMPLING_YUV422;
|
||||
// デフォルトの品質
|
||||
static const int c_nDefaultQuality = 80;
|
||||
|
||||
// デフォルトのサムネイル付加フラグ
|
||||
static const int c_bDefaultAddThumbnailFlag = true;
|
||||
// デフォルトのサムネイルのJPEGフォーマット
|
||||
static const nn::jpeg::CTR::PixelSampling c_eDefaultThumbnailFormat = nn::jpeg::CTR::DEFAULT_THUMBNAIL_PIXEL_SAMPLING;
|
||||
// デフォルトのサムネイルの幅
|
||||
static const int c_nDefaultThumbnailWidth = nn::jpeg::CTR::DEFAULT_THUMBNAIL_WIDTH;
|
||||
// デフォルトのサムネイルの高さ
|
||||
static const int c_nDefaultThumbnailHeight = nn::jpeg::CTR::DEFAULT_THUMBNAIL_HEIGHT;
|
||||
// デフォルトのサムネイルサイズ自動調整の有効フラグ
|
||||
static const bool c_bDefaultAutoThumbnailSizeFlag = true;
|
||||
|
||||
// タイトルユーニークIDの文字数
|
||||
static const int c_nTitleUniqueIdStringLength = 5;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegMpBaseEncoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegMpBaseEncoder() = 0;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
JPEG設定関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGのフォーマットを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
nn::jpeg::CTR::PixelSampling GetJpegFormat() const { return m_eJpegFormat; }
|
||||
void SetJpegFormat(nn::jpeg::CTR::PixelSampling eFormat){ m_eJpegFormat = eFormat; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGの品質を取得/設定する
|
||||
@details
|
||||
1~100までの値で大きいほど高品質になります。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetQuality() const { return m_nQuality; }
|
||||
void SetQuality(int nQuality){ m_nQuality = nQuality; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイル付加フラグを取得/設定する
|
||||
@details
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetAddThumbnailFlag() const { return m_bAddThumbnailFlag; }
|
||||
void SetAddThumbnailFlag(bool bAdd){ m_bAddThumbnailFlag = bAdd; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイルのフォーマットを取得/設定する
|
||||
@details
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
nn::jpeg::CTR::PixelSampling GetThumbnailFormat() const { return m_eThumbnailFormat; }
|
||||
void SetThumbnailFormat(nn::jpeg::CTR::PixelSampling eFormat){ m_eThumbnailFormat = eFormat; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイルの幅と高さを取得/設定する
|
||||
@details
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetThumbnailWidth() const { return m_nThumbnailWidth; }
|
||||
void SetThumbnailWidth(int nWidth){ m_nThumbnailWidth = nWidth; }
|
||||
int GetThumbnailHeight() const { return m_nThumbnailHeight; }
|
||||
void SetThumbnailHeight(int nHeight){ m_nThumbnailHeight = nHeight; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイルサイズ自動調整の有効フラグを取得/設定する
|
||||
@details
|
||||
この機能を有効にすると、SetThumbnailWidth()、SetThumbnailHeight()は無視
|
||||
され、エンコード時にc_nDefaultThumbnailWidth, c_nDefaultThumbnailHeight
|
||||
サイズ以下でアスペクト比保ったサムネイルサイズに設定されます。
|
||||
デフォルト値はImageDb推奨値です。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool GetEnableAutoThumbnailSizeFlag() const { return m_bAutoThumbnailSizeFlag; }
|
||||
void SetEnableAutoThumbnailSizeFlag(bool bEnable){ m_bAutoThumbnailSizeFlag = bEnable; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGのフォーマットで要求される画像サイズの単位を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
int GetWidthUnit() const { return GetWidthUnit(GetJpegFormat()); }
|
||||
int GetHeightUnit() const { return GetHeightUnit(GetJpegFormat()); }
|
||||
static int GetWidthUnit(nn::jpeg::CTR::PixelSampling eFormat);
|
||||
static int GetHeightUnit(nn::jpeg::CTR::PixelSampling eFormat);
|
||||
//@}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
EXIF関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影日時情報を取得/設定する
|
||||
@details
|
||||
デフォルトではこのクラスが生成された時の時間となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
nn::fnd::DateTime GetDateTime() const{ return m_DateTime; }
|
||||
void SetDateTime(const nn::fnd::DateTime& rDateTime){ m_DateTime = rDateTime; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ユーザメーカーノートのデータを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetUserMakerNoteData() const;
|
||||
std::size_t GetUserMakerNoteDataSize() const;
|
||||
void SetUserMakerNoteData(const void* pData, std::size_t nSize);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ソフトウェア名を取得/設定する
|
||||
@details
|
||||
ヌルを渡した場合は指定なしとして扱われます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const char* GetSoftware() const;
|
||||
void SetSoftware(const char* pSoftware);
|
||||
//@}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
システムメーカーノート関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートを取得/設定する
|
||||
@return 設定に成功した場合はtrue
|
||||
@details
|
||||
設定はフォーマット確認用コード等が適切に設定されたデータを指定しないと
|
||||
失敗します。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const SysMakerNote& GetSysMakerNote() const;
|
||||
bool SetSysMakerNote(const void* pNote);
|
||||
bool SetSysMakerNote(const SysMakerNote& rNote);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief フォーマット確認用コードを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSysMakerNoteCode() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのファイル作成時間を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetSysMakerNoteCreateSecond() const;
|
||||
void SetSysMakerNoteCreateSecond(const DateTimeSeconds& rDTSecs);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのタイトルユニークIDをチェック/取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool IsValidSysMakerNoteTitleUniqueId() const;
|
||||
u32 GetSysMakerNoteTitleUniqueId() const;
|
||||
void SetSysMakerNoteTitleUniqueId(u32 nUId);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの保存プロセスを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
SaveProcessType GetSysMakerNoteSaveProcessType() const;
|
||||
void SetSysMakerNoteSaveProcessType(SaveProcessType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの操作フラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
HandleTypeBit GetSysMakerNoteHandleFlag() const;
|
||||
void SetSysMakerNoteHandleFlag(HandleTypeBit eFlag);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの本体IDの有効チェック/取得/設定/リセットする
|
||||
@param[in] eType 本体IDのタイプ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool IsValidSysMakerNoteBodyId(BodyIdType eType) const;
|
||||
u32 GetSysMakerNoteBodyId(BodyIdType eType) const;
|
||||
void SetSysMakerNoteBodyId(BodyIdType eType, u32 nId);
|
||||
void ResetSysMakerNoteBodyId(BodyIdType eType);
|
||||
//@}
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの本体IDをローカルユニークIDで設定する
|
||||
@param[in] eType 設定する本体IDのタイプ
|
||||
@param[in] nLUId ローカルユニークID
|
||||
-----------------------------------------------------------------------*/
|
||||
//void SetSysMakerNoteIdByLocalUniqId(BodyIdType eType, u32 nLUId);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのMPファイル水平オフセット値を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
f32 GetSysMakerNoteMpOffsetH() const;
|
||||
void SetSysMakerNoteMpOffsetH(f32 fOfstH);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのお気に入り順を取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
s32 GetSysMakerNoteLegacyFavoriteOrder() const;
|
||||
void SetSysMakerNoteLegacyFavoriteOrder(s32 nOrder);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのお気に入りタイプを取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyFavoriteType GetSysMakerNoteLegacyFavoriteType() const;
|
||||
void SetSysMakerNoteLegacyFavoriteType(LegacyFavoriteType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの画像タイプを取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyImageType GetSysMakerNoteLegacyImageType() const;
|
||||
void SetSysMakerNoteLegacyImageType(LegacyImageType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの署名の鍵タイプを取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyKeyType GetSysMakerNoteLegacyKeyType() const;
|
||||
void SetSysMakerNoteLegacyKeyType(LegacyKeyType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのデフォルトフレーム状態を取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool IsSysMakerNoteLegacyDefaultFrame() const;
|
||||
void SetSysMakerNoteLegacyDefaultFrame(bool bDefault);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの撮影タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ShootingType GetSysMakerNoteShootingType() const;
|
||||
void SetSysMakerNoteShootingType(ShootingType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートの写真特徴フラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
DistinctionTypeBit GetSysMakerNoteDistinctionTypeBit() const;
|
||||
void SetSysMakerNoteDistinctionTypeBit(DistinctionTypeBit eBit);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを文字列に変換する
|
||||
@param[out] pStr 生成した文字列を格納するバッファ
|
||||
@param[in] nSize バッファサイズ(文字数)
|
||||
@param[in] nId 変換するタイトルユニークID
|
||||
@details
|
||||
バッファはc_nTitleUniqueIdStringLength+1以上のバッファである必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
static void ConvTitleUniqueIdToString(char* pStr, int nSize, u32 nId);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 文字列をタイトルユニークIDに変換する
|
||||
@param[out] rId 変換したID
|
||||
@param[in] pStr 変換する文字列
|
||||
@return 変換に成功した場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
static bool ConvStringToTitleUniqueId(u32& rId, const char* pStr);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サンプリングタイプに応じた1ピクセルのデータサイズを取得する
|
||||
@return サイズ(ビット単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static int GetPixelSamplingPixelPerBit(nn::jpeg::CTR::PixelSampling eJpegFormat);
|
||||
|
||||
protected:
|
||||
const void* GetSystemMakerNoteData() const;
|
||||
std::size_t GetSystemMakerNoteDataSize() const;
|
||||
|
||||
static int GetImageWidthAlign(nn::jpeg::CTR::PixelSampling eJpegFormat);
|
||||
static int GetImageHeightAlign(nn::jpeg::CTR::PixelSampling eJpegFormat);
|
||||
|
||||
static void ComputeAutoThumbnailSize(
|
||||
int& rThumbWidth, int& rThumbHeight,
|
||||
int nImageWidth, int nImageHeight, nn::jpeg::CTR::PixelSampling eJpegFormat);
|
||||
|
||||
private:
|
||||
// 変換情報
|
||||
nn::jpeg::CTR::PixelSampling m_eJpegFormat;
|
||||
int m_nQuality;
|
||||
bool m_bAddThumbnailFlag;
|
||||
nn::jpeg::CTR::PixelSampling m_eThumbnailFormat;
|
||||
int m_nThumbnailWidth;
|
||||
int m_nThumbnailHeight;
|
||||
bool m_bAutoThumbnailSizeFlag;
|
||||
nn::fnd::DateTime m_DateTime;
|
||||
const void* m_pUserMakerNoteData;
|
||||
std::size_t m_nUserMakerNoteDataSize;
|
||||
const char* m_pSoftware;
|
||||
SysMakerNote m_SysMakerNote;
|
||||
bool m_bValidSysMakerNoteTitleUniqueId;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEGエンコードクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class JpegEncoder : public JpegMpBaseEncoder, private nn::util::NonCopyable<JpegEncoder>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] pRawData 生データ
|
||||
@param[in] RawFormat 生データのフォーマット
|
||||
@param[in] nWidth 幅(ピクセル単位)
|
||||
@param[in] nHeight 高さ(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegEncoder(
|
||||
const void* pRawData, nn::jpeg::CTR::PixelFormat eRawFormat,
|
||||
int nWidth, int nHeight);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegEncoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief エンコードする
|
||||
@param[in] bTwlCompatible TWL互換フラグ
|
||||
@details
|
||||
bTwlCompatibleをtrueにするとTWLで扱えるJPEGとしてエンコードします。
|
||||
その場合画像サイズなどが適正でない場合失敗します。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Encode(bool bTwlCompatible=false);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
エンコード関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief エンコードしたJPEGデータを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetJpegData() const { return m_pJpegData; }
|
||||
void* GetJpegData(){
|
||||
return const_cast<void*>(static_cast<const JpegEncoder&>(*this).GetJpegData()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief エンコードしたJPEGデータのサイズを取得する
|
||||
@return データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetJpegSize() const { return m_nJpegSize; }
|
||||
|
||||
private:
|
||||
static std::size_t ComputeJpegDataSize(
|
||||
nn::jpeg::CTR::PixelSampling eJpegFormat,
|
||||
int nWidth, int nHeight,
|
||||
int nQuality, bool bTwlCompatible=false);
|
||||
|
||||
static int ComputeDownQuality(int nCurQuality);
|
||||
|
||||
private:
|
||||
// 変換前のデータ
|
||||
const void* m_pRawData;
|
||||
nn::jpeg::CTR::PixelFormat m_eRawFormat;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
|
||||
// 変換後のデータ
|
||||
u8* m_pJpegData;
|
||||
std::size_t m_nJpegDataSize; // m_pJpegDataのバッファサイズ
|
||||
std::size_t m_nJpegSize; // m_pJpegDataに格納したJPEGデータサイズ
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief MPエンコードクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class MpEncoder : public JpegMpBaseEncoder, private nn::util::NonCopyable<MpEncoder>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] pRawDataL 左目側の生データ
|
||||
@param[in] pRawDataR 右目側の生データ
|
||||
@param[in] RawFormat 生データのフォーマット
|
||||
@param[in] nWidth 幅(ピクセル単位)
|
||||
@param[in] nHeight 高さ(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
MpEncoder(
|
||||
const void* pRawDataL, const void* pRawDataR, nn::jpeg::CTR::PixelFormat eRawFormat,
|
||||
int nWidth, int nHeight);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~MpEncoder();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief エンコードする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool Encode();
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
エンコード関連
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief エンコードしたMPデータを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const void* GetMpData() const { return m_pMpData; }
|
||||
void* GetMpData(){
|
||||
return const_cast<void*>(static_cast<const MpEncoder&>(*this).GetMpData()); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief エンコードしたMPデータのサイズを取得する
|
||||
@return データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetMpSize() const { return m_nMpSize; }
|
||||
|
||||
|
||||
private:
|
||||
static std::size_t ComputeMpDataSize(
|
||||
nn::jpeg::CTR::PixelSampling eJpegFormat, int nWidth, int nHeight, int nQuality);
|
||||
static int ComputeDownQuality(int nCurQuality, int nMpPass);
|
||||
|
||||
private:
|
||||
// 変換前のデータ
|
||||
const void* m_pRawDataL;
|
||||
const void* m_pRawDataR;
|
||||
nn::jpeg::CTR::PixelFormat m_eRawFormat;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
|
||||
// 変換後のデータ
|
||||
u8* m_pMpData;
|
||||
std::size_t m_nMpDataSize; // m_pMpDataのバッファサイズ
|
||||
std::size_t m_nMpSize; // m_pMpDataに格納したMPデータサイズ
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // JPEG_MP_ENCODER_H_
|
||||
206
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/SysMakerNote.h
Normal file
206
trunk/SkipFirstLaunch/ImageDb/include/imgdb/Core/SysMakerNote.h
Normal file
@ -0,0 +1,206 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: SysMakerNote.h
|
||||
|
||||
システムメーカーノート
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef SYS_MAKER_NOTE_H_
|
||||
#define SYS_MAKER_NOTE_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbTypes.h"
|
||||
#include "ImageDbDateTimeSeconds.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief システムメーカーノート構造体(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct SysMakerNote
|
||||
{
|
||||
u32 nCode; // フォーマット確認用コード
|
||||
s32 nSaveProcess; // 保存過程の種類
|
||||
DateTimeSeconds sCreateSeconds; // ファイル作成日時
|
||||
u32 nTitleUniqueId; // タイトルユニークID(ソフトウェアID)
|
||||
u16 nHandleFlags; // 取り扱いフラグ HandleTypeBit列挙型の論理和
|
||||
u16 nValidBodyIdFlag; // 有効な本体IDのフラグ BodyIdTypeBit列挙型の論理和
|
||||
u32 nBodyId[BodyIdTypeNum]; // 本体ID
|
||||
f32 fMpOffsetH; // MPファイルの水平オフセット
|
||||
s32 nFavoriteOrder; // DSi互換用(レガシー)
|
||||
u32 nCharacterFlag; // 2 : LegacyFavoriteType列挙型(レガシー)
|
||||
// 2 : LegacyImageType列挙型(レガシー)
|
||||
// 2 : LegacyKeyType列挙型(レガシー)
|
||||
// 1 : bool デフォルトフレーム(レガシー)
|
||||
// 5 : ShootingType列挙型 撮影モード
|
||||
// 16 : DistinctionTypeBit列挙型 写真特徴タイプ
|
||||
// 4 : Reserved
|
||||
u32 reserved[3];
|
||||
|
||||
|
||||
//! フォーマット確認用コード
|
||||
static const u32 c_nValidCode = 0x31534433; // '3DS1'
|
||||
|
||||
static const int c_nChaFlagLegacyFavoriteTypeBits = 2;
|
||||
static const int c_nChaFlagLegacyFavoriteTypeShift = 0;
|
||||
static const u32 c_nChaFlagLegacyFavoriteTypeMask = ((1UL<<c_nChaFlagLegacyFavoriteTypeBits)-1)<<c_nChaFlagLegacyFavoriteTypeShift;
|
||||
|
||||
static const int c_nChaFlagLegacyImageTypeBits = 2;
|
||||
static const int c_nChaFlagLegacyImageTypeShift = c_nChaFlagLegacyFavoriteTypeBits + c_nChaFlagLegacyFavoriteTypeShift;
|
||||
static const u32 c_nChaFlagLegacyImageTypeMask = ((1UL<<c_nChaFlagLegacyImageTypeBits)-1)<<c_nChaFlagLegacyImageTypeShift;
|
||||
|
||||
static const int c_nChaFlagLegacyKeyTypeBits = 2;
|
||||
static const int c_nChaFlagLegacyKeyTypeShift = c_nChaFlagLegacyImageTypeBits + c_nChaFlagLegacyImageTypeShift;
|
||||
static const u32 c_nChaFlagLegacyKeyTypeMask = ((1UL<<c_nChaFlagLegacyKeyTypeBits)-1)<<c_nChaFlagLegacyKeyTypeShift;
|
||||
|
||||
static const int c_nChaFlagLegacyDefaultFrameBits = 1;
|
||||
static const int c_nChaFlagLegacyDefaultFrameShift = c_nChaFlagLegacyKeyTypeBits + c_nChaFlagLegacyKeyTypeShift;
|
||||
static const u32 c_nChaFlagLegacyDefaultFrameMask = ((1UL<<c_nChaFlagLegacyDefaultFrameBits)-1)<<c_nChaFlagLegacyDefaultFrameShift;
|
||||
|
||||
static const int c_nChaFlagShootingTypeBits = 5;
|
||||
static const int c_nChaFlagShootingTypeShift = c_nChaFlagLegacyDefaultFrameBits + c_nChaFlagLegacyDefaultFrameShift;
|
||||
static const u32 c_nChaFlagShootingTypeMask = ((1UL<<c_nChaFlagShootingTypeBits)-1)<<c_nChaFlagShootingTypeShift;
|
||||
|
||||
static const int c_nChaFlagDistinctionTypeBitBits = 16;
|
||||
static const int c_nChaFlagDistinctionTypeBitShift = c_nChaFlagShootingTypeBits + c_nChaFlagShootingTypeShift;
|
||||
static const u32 c_nChaFlagDistinctionTypeBitMask = ((1UL<<c_nChaFlagDistinctionTypeBitBits)-1)<<c_nChaFlagDistinctionTypeBitShift;
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 構造体を初期化する
|
||||
@param[in] eImgKind 初期化対象の映像種類
|
||||
@details
|
||||
デフォルト値で構造体を初期化します。
|
||||
レガシー関連のパラメータは普段設定する必要はないはずのため、不要な場合は
|
||||
デフォルト値のままにしておいてください。
|
||||
eImgKindを省略すると写真として初期化されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
void Initialize();
|
||||
void Initialize(ImageKind eImgKind);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief フォーマット確認コードを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetCode() const{ return nCode; }
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存過程を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
SaveProcessType GetSaveProcessType() const{ return static_cast<SaveProcessType>(nSaveProcess); }
|
||||
void SetSaveProcessType(SaveProcessType eType){ nSaveProcess = eType; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル作成日時を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const DateTimeSeconds& GetCreateSeconds() const{ return sCreateSeconds; }
|
||||
void SetCreateSeconds(const DateTimeSeconds& rDTSecs){ sCreateSeconds = rDTSecs; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u32 GetTitleUniqueId() const{ return nTitleUniqueId; }
|
||||
void SetTitleUniqueId(u32 nUId){ nTitleUniqueId = nUId; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 取り扱いビットを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
HandleTypeBit GetHandleTypeBit() const{ return static_cast<HandleTypeBit>(nHandleFlags); }
|
||||
void SetHandleTypeBit(HandleTypeBit eBit){ nHandleFlags = eBit; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 本体IDの有効チェック/取得/設定/リセットする
|
||||
@param[in] eType 本体IDのタイプ
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
BodyIdTypeBit GetValidBodyIdBit() const{ return static_cast<BodyIdTypeBit>(nValidBodyIdFlag); }
|
||||
bool IsValidBodyId(BodyIdType eType) const{ return (nValidBodyIdFlag & (1<<eType)); }
|
||||
u32 GetBodyId(BodyIdType eType) const{ return nBodyId[eType]; }
|
||||
void SetBodyId(BodyIdType eType, u32 nBodyId){ this->nBodyId[eType] = nBodyId; nValidBodyIdFlag |= 1<<eType; }
|
||||
void ResetBodyId(BodyIdType eType){ nBodyId[eType] = 0; nValidBodyIdFlag &= ~(1<<eType); }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルの水平オフセットを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
f32 GetMpOffsetH() const{ return fMpOffsetH; }
|
||||
void SetMpOffsetH(f32 fH){ fMpOffsetH = fH; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief お気に入り順を取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
s32 GetFavoriteOrder() const{ return nFavoriteOrder; }
|
||||
void SetFavoriteOrder(s32 nOrder){ nFavoriteOrder = nOrder; }
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief お気に入りタイプを取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyFavoriteType GetLegacyFavoriteType() const;
|
||||
void SetLegacyFavoriteType(LegacyFavoriteType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 画像タイプを取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyImageType GetLegacyImageType() const;
|
||||
void SetLegacyImageType(LegacyImageType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 署名の鍵タイプを取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
LegacyKeyType GetLegacyKeyType() const;
|
||||
void SetLegacyKeyType(LegacyKeyType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デフォルトフレーム状態を取得/設定する(レガシー)
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
bool IsLegacyDefaultFrame() const;
|
||||
void SetLegacyDefaultFrame(bool bDefault);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影タイプを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
ShootingType GetShootingType() const;
|
||||
void SetShootingType(ShootingType eType);
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真特徴タイプのビットフラグを取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
DistinctionTypeBit GetDistinctionTypeBit() const;
|
||||
void SetDistinctionTypeBit(DistinctionTypeBit eBit);
|
||||
//@}
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // SYS_MAKER_NOTE_H_
|
||||
@ -0,0 +1,222 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: SysMakerNoteRewriter.h
|
||||
|
||||
システムメーカーノート書き換え
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef SYS_MAKER_NOTE_REWRITER_H_
|
||||
#define SYS_MAKER_NOTE_REWRITER_H_
|
||||
|
||||
#include "ImageDbRecord.h"
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
#include "ImageDbNmjPlayerConfig.h"
|
||||
#include "../../Movie/nmjPlayer.h"
|
||||
#endif // IMAGE_DB_IMAGE_UTILITY_H_
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief システムメーカーノート書き換え抽象クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class SysMakerNoteRewriterBase
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
SysMakerNoteRewriterBase();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~SysMakerNoteRewriterBase() = 0;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き換える
|
||||
@details
|
||||
設定されている内容に書き換えます。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Rewrite() = 0;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル作成時間が設定されているかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsStoredCreateSeconds() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル作成時間を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
const DateTimeSeconds& GeCreateSeconds() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル作成時間を設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetCreateSeconds(const DateTimeSeconds& rDTSecs);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ファイル作成時間をリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetCreateSeconds();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルの水平オフセットが設定されているかチェックする
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsStoredMpOffsetH() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルの水平オフセットを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
f32 GetMpOffsetH() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルの水平オフセットを設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetMpOffsetH(f32 fOfst);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルの水平オフセットをリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetMpOffsetH();
|
||||
|
||||
protected:
|
||||
void ResetStoredFlagAll();
|
||||
|
||||
bool IsNeedRewriteJpeg() const;
|
||||
bool IsNeedRewriteMp() const;
|
||||
bool IsNeedRewriteMJpeg() const;
|
||||
|
||||
protected:
|
||||
// ファイル作成時間
|
||||
bool m_bStoredCreateSeconds;
|
||||
DateTimeSeconds m_sCreateSeconds;
|
||||
|
||||
// MPファイルの水平オフセット
|
||||
bool m_bStoredMpOffsetH;
|
||||
f32 m_fMpOffsetH;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief レコードリンクからファイルのシステムメーカーノート書き換えクラス
|
||||
@details
|
||||
コンストラクタで渡されたレコードリンクのファイルを直接書き換えるクラスです。
|
||||
NANDのJPEGであればTWL側も、MPであれば対となるJPEGも書き換えます。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class SysMakerNoteDbRecordRewriter : public SysMakerNoteRewriterBase
|
||||
, private nn::util::NonCopyable<SysMakerNoteDbRecordRewriter>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] rFileInfo 書き換え対象の動画情報
|
||||
@param[in] rLink 書き換え対象の映像のレコードリンク
|
||||
@details
|
||||
写真の場合はrLinkを渡すコンストラクタを使用してください。
|
||||
動画の場合はどちらでも使用出来ますが、rFileInfoを指定する方が処理が若干
|
||||
早くなります。
|
||||
rFileInfoを省略した場合は、Rewrite()内で情報の抽出が行われますが、その処
|
||||
理は同時に実行することができません。
|
||||
スレッドで動かす場合は独自に排他制御するなどして、情報の抽出が衝突しない
|
||||
ように気をつけてください。
|
||||
rFileInfoは内部でコピーされるため設定後は破棄しても構いません。
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
explicit SysMakerNoteDbRecordRewriter(const ImageDbRecordLink& rLink);
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
SysMakerNoteDbRecordRewriter(const nmj::player::FileInfo& rFileInfo, const ImageDbRecordLink& rLink);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~SysMakerNoteDbRecordRewriter();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き換える
|
||||
@details
|
||||
設定されている内容に書き換えます。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Rewrite();
|
||||
|
||||
private:
|
||||
bool RewriteJpeg(const ImageInfo& rImgInfo, bool bTwlCompatible);
|
||||
bool RewriteMp(const ImageInfo& rImgInfo);
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
bool RewriteMJpeg(
|
||||
const nmj::player::FileInfo& rFileInfo, const ImageInfo& rImgInfo);
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
|
||||
bool RewriteData(
|
||||
StorageType eStoType, nn::fs::FileOutputStream& rStream,
|
||||
int nOfst, const void* pData, std::size_t nDataSize) const;
|
||||
|
||||
private:
|
||||
const ImageDbRecordLink m_Link;
|
||||
#if defined(IMGDB_ENABLE_MOVIE)
|
||||
nmj::player::FileInfo m_FInfoWork;
|
||||
nmj::player::FileInfo* m_pFInfo;
|
||||
|
||||
// このメンバ変数はstaticを付けなくても、内部ではstaticな値を持って
|
||||
// いるため排他で扱う必要があります。
|
||||
static util::NmjPlayerConfig<Const::NmjPlayerConfigIdSysNoteRw> m_Config;
|
||||
#endif // defined(IMGDB_ENABLE_MOVIE)
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 画像データのシステムメーカーノート書き換えクラス
|
||||
@details
|
||||
コンストラクタでJPEG/MPデータを直接書き換えるクラスです。
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_suppress 1301 // パディング警告の抑制
|
||||
#pragma diag_suppress 2530 // パディング情報の抑制
|
||||
class SysMakerNoteDataRewriter : public SysMakerNoteRewriterBase
|
||||
, private nn::util::NonCopyable<SysMakerNoteDbRecordRewriter>
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
@param[in] eImgKind 画像の種類
|
||||
@param[io] pJpegMpData 書き換え対象の画像データ
|
||||
@param[in] nJpegMpDataSize 画像データサイズ
|
||||
-----------------------------------------------------------------------*/
|
||||
SysMakerNoteDataRewriter(ImageKind eImgKind, void* pJpegMpData, std::size_t nJpegMpDataSize);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~SysMakerNoteDataRewriter();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 書き換える
|
||||
@details
|
||||
設定されている内容に書き換えます。
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual bool Rewrite();
|
||||
|
||||
private:
|
||||
bool RewriteJpeg(void* pJpegData, std::size_t nJpegDataSize);
|
||||
bool RewriteMp(void* pMpData, std::size_t nMpDataSize);
|
||||
|
||||
private:
|
||||
ImageKind m_eImgKind;
|
||||
void* m_pJpegMpData;
|
||||
std::size_t m_nJpegMpDataSize;
|
||||
};
|
||||
#pragma diag_default 2530 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // SYS_MAKER_NOTE_REWRITER_H_
|
||||
@ -0,0 +1,88 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: UserMakerNote.h
|
||||
|
||||
PNOTEの写真に格納されるユーザーメーカーノート
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef USER_MAKER_NOTE_
|
||||
#define USER_MAKER_NOTE_
|
||||
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include "ImageDbFaceInfo.h"
|
||||
#include "ImageDbConst.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ユーザーメーカーノート ヘッダ部(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct UserMakerNoteHeader
|
||||
{
|
||||
u16 nVersion; // バージョン番号
|
||||
u16 nReserved0[3]; // 予約
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 構造体を初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief バージョン番号を取得/設定する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
u16 GetVersion() const{ return nVersion; }
|
||||
void SetVersion(u16 nVer){ nVersion = nVer; }
|
||||
//@}
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief ユーザーメーカーノート(POD)
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma push
|
||||
#pragma diag_error 1301 // パディングをエラーにする
|
||||
struct UserMakerNote
|
||||
{
|
||||
UserMakerNoteHeader sHeader;
|
||||
|
||||
// 顔情報
|
||||
FaceInfo sFaceInfo[Const::c_nMaxFaceInfoNum];
|
||||
|
||||
static const u16 c_nVersion = 0x0001;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 構造体を初期化する
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ヘッダを取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const UserMakerNoteHeader& GetHeader() const;
|
||||
UserMakerNoteHeader& GetHeader();
|
||||
//@}
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔情報を取得する
|
||||
-----------------------------------------------------------------------*/
|
||||
//@{
|
||||
const FaceInfo& GetFaceInfo(int nIndex) const;
|
||||
FaceInfo& GetFaceInfo(int nIndex);
|
||||
//@}
|
||||
};
|
||||
#pragma diag_default 1301 // TODO #pragma push/popが修正され次第削除
|
||||
#pragma pop
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // USER_MAKER_NOTE_
|
||||
60
trunk/SkipFirstLaunch/ImageDb/include/imgdb/ImageDb.h
Normal file
60
trunk/SkipFirstLaunch/ImageDb/include/imgdb/ImageDb.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageDb.h
|
||||
|
||||
ImageDatabaseƒ<EFBFBD>ƒCƒ“ƒwƒbƒ_ƒtƒ@ƒCƒ‹
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_DB_H_
|
||||
#define IMAGE_DB_H_
|
||||
|
||||
#include "Core/ImageDbDebug.h"
|
||||
|
||||
#include "Core/ImageDbAllocator.h"
|
||||
#include "Core/ImageDbDynamicArray.h"
|
||||
#include "Core/ImageDbArchiveMounter.h"
|
||||
#include "Core/ImageDbNmjPlayerConfig.h"
|
||||
#include "Core/ImageDbNmjRecordingConfig.h"
|
||||
|
||||
#include "Core/ImageDbFaceInfo.h"
|
||||
#include "Core/ImageDbCrc.h"
|
||||
#include "Core/ImageDbDateTimeSeconds.h"
|
||||
|
||||
#include "Core/ImageDbTypes.h"
|
||||
#include "Core/ImageDbResult.h"
|
||||
#include "Core/ImageDbConst.h"
|
||||
#include "Core/ImageDbImageInfo.h"
|
||||
|
||||
#include "Core/ImageDbValidityStateTable.h"
|
||||
#include "Core/ImageDbRecord.h"
|
||||
#include "Core/ImageDbLegacyTable.h"
|
||||
#include "Core/ImageDbPictureTable.h"
|
||||
#include "Core/ImageDbPictureDatabase.h"
|
||||
|
||||
#include "Core/ImageDatabase.h"
|
||||
#include "Core/ImageDbInit.h"
|
||||
#include "Core/ImageDbInitEx.h"
|
||||
#include "Core/ImageDbDirectory.h"
|
||||
#include "Core/ImageDbUtility.h"
|
||||
#include "Core/ImageDbImageValidator.h"
|
||||
#include "Core/ImageDbFileReader.h"
|
||||
#include "Core/ImageDbFileWriter.h"
|
||||
#include "Core/ImageDbRestore.h"
|
||||
#include "Core/ImageDbSearchObject.h"
|
||||
#include "Core/ImageDbFileDuplicator.h"
|
||||
#include "Core/ImageDbRecordParam.h"
|
||||
#include "Core/ImageDbImageSearcher.h"
|
||||
#include "Core/ImageDbImageCollector.h"
|
||||
#include "Core/JpegMpDecoder.h"
|
||||
#include "Core/JpegMpEncoder.h"
|
||||
#include "Core/SysMakerNote.h"
|
||||
#include "Core/SysMakerNoteRewriter.h"
|
||||
#include "Core/UserMakerNote.h"
|
||||
|
||||
#include "ImageIO/ImageIOTypes.h"
|
||||
#include "ImageIO/ImageIOArchiveMount.h"
|
||||
#include "ImageIO/JpegMpLoader.h"
|
||||
#include "ImageIO/JpegMpSaver.h"
|
||||
#include "ImageIO/JpegMpSaverEx.h"
|
||||
|
||||
|
||||
#endif // IMAGE_DB_H_
|
||||
48
trunk/SkipFirstLaunch/ImageDb/include/imgdb/ImageIO.h
Normal file
48
trunk/SkipFirstLaunch/ImageDb/include/imgdb/ImageIO.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageIO.h
|
||||
|
||||
ImageIO メインヘッダ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_IO_H_
|
||||
#define IMAGE_IO_H_
|
||||
|
||||
/*! @namespace imgdb
|
||||
@brief ImageDb の名前空間
|
||||
|
||||
@defgroup imgdb_root imgdb
|
||||
@brief ルートとなるモジュール
|
||||
*/
|
||||
|
||||
/*! @namespace imgdb::imgio
|
||||
@brief ImageDb の公開ライブラリ関連の名前空間
|
||||
*/
|
||||
|
||||
/*! @namespace imgdb::util
|
||||
@brief ImageDb のユーティリティ関連の名前空間
|
||||
*/
|
||||
|
||||
/*! @namespace imgdb::mnt
|
||||
@brief ImageDb のアーカイブのマウント制御関連の名前空間
|
||||
*/
|
||||
|
||||
/*! @namespace imgdb::search
|
||||
@brief ImageDb の写真検索関連の名前空間
|
||||
*/
|
||||
|
||||
|
||||
#include "Core/ImageDbInit.h"
|
||||
#include "ImageIO/ImageIOTypes.h"
|
||||
#include "ImageIO/ImageIOArchiveMount.h"
|
||||
#include "ImageIO/ImageIOSearch.h"
|
||||
#include "ImageIO/JpegMpLoader.h"
|
||||
#include "ImageIO/JpegMpSaver.h"
|
||||
#include "ImageIO/ImageIOUtility.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
|
||||
#endif // IMAGE_IO_H_
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageIOArchiveMount.h
|
||||
|
||||
ファイルシステムのアーカイブマウント
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_IO_ARCHIVE_MOUNT_H_
|
||||
#define IMAGE_IO_ARCHIVE_MOUNT_H_
|
||||
|
||||
#include "../Core/ImageDbResult.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace mnt {
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ImageDbが利用するSDカードアーカイブがマウントされているかチェックする
|
||||
@return マウントされている場合はtrue
|
||||
@details
|
||||
実際の活線挿抜に対応するにはnn::fs::RegisterSdmcInsertedEvent等を使用し
|
||||
てください。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsMountSdmc();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ImageDbが利用するSDカードアーカイブをマウントする
|
||||
@return マウントに成功した場合はtrue
|
||||
@details
|
||||
既にマウントされている場合は何もせずにfalseを終了します。<BR>
|
||||
imgdb::Initialize()呼び出し内でSDカードアーカイブはマウントされています
|
||||
が(SDカードが挿されていれば)、 その後SDカードが抜き差しされた場合は
|
||||
アプリ側でマウントしなおす必要があります。<BR>
|
||||
SDカードが挿されたらアプリ側で本関数を呼び出してマウントしてください。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool MountSdmc();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ImageDbが利用するSDカードアーカイブをアンマウントする
|
||||
@details
|
||||
既にアンマウントされている場合は何もせずに終了します。<BR>
|
||||
imgdb::Finalize()呼び出し内でSDカードアーカイブはアンマウントされますが、
|
||||
その前にSDカードが抜き差しされた場合はアプリ側でマウントしなおす必要が
|
||||
あります。<BR>
|
||||
SDカードが抜かれたらアプリ側で本関数を呼び出してアンマウントしてください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void UnmountSdmc();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief SDカードアーカイブの状態をチェックする
|
||||
@return SDカードの状態結果
|
||||
@details
|
||||
この関数はSDカードの状態をチェックし、以下の戻り値を返します。<BR>
|
||||
ResultSuccess<BR>
|
||||
ResultErrorNotExistStorage<BR>
|
||||
ResultErrorNotAvailableStorage<BR>
|
||||
ResultErrorWriteProtect
|
||||
-----------------------------------------------------------------------*/
|
||||
Result CheckSdmcState();
|
||||
|
||||
|
||||
|
||||
} // end of namespace mnt
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_IO_ARCHIVE_MOUNT_H_
|
||||
@ -0,0 +1,106 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageIOSearch.h
|
||||
|
||||
写真の列挙検索を提供します。
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_IO_SEARCH_H_
|
||||
#define IMAGE_IO_SEARCH_H_
|
||||
|
||||
#include <nn/fnd.h>
|
||||
#include "ImageIOTypes.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace search {
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真検索機能の初期化を行う
|
||||
@details
|
||||
写真の列挙検索を利用する前に1度だけ呼び出す必要があります。<BR>
|
||||
imgdb::Initialize()後に呼び出す必要があります。<BR>
|
||||
本関数を呼び出すと Finalize() が呼ばれるまで 24KB 程のメモリ消費されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Initialize();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真検索機能を終了させる
|
||||
@details
|
||||
imgdb::Finalize()前に呼び出してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void Finalize();
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief ImageDb に管理されている写真を検索する
|
||||
@details
|
||||
ImageDb に管理されている写真を検索し、その結果を内部に保存します。<BR>
|
||||
検索した結果は GetTitleUniqueId() や GetPath() などにインデックスを指定
|
||||
して取得できます。<BR>
|
||||
検索結果は撮影日時をもとに昇順で並んでいます(インデックスが小さいと古
|
||||
い写真、大きいと新しい写真)。<BR>
|
||||
PC上でSDカードに直接写真を追加削除された場合などに、それらの写真を管理す
|
||||
るためには、CollectPicture()を呼び出す必要があります。<BR>
|
||||
|
||||
SDカードが存在しない、または認識できていない場合は、検索結果ゼロとして
|
||||
正常終了します。<BR>
|
||||
|
||||
内部で保存されている検索結果は、以下のイベントや操作で無効になります。<BR>
|
||||
無効な状態で Get~() を呼び出すと、アサートの発生や間違った情報を返す場
|
||||
合があるため、呼び出しは避けてください。<BR>
|
||||
再度 SearchPicture() で検索しなおすことで有効な状態に戻ります。<BR>
|
||||
・SDカードが差されたとき<BR>
|
||||
・SDカードが抜かれたとき<BR>
|
||||
・JpegSaver/MpSaverで写真を保存したとき<BR>
|
||||
・DeletePicture()で写真を削除したとき<BR>
|
||||
・CollectPicture()で管理ファイルを更新したとき<BR>
|
||||
・HOMEメニューから戻ったとき(HOMEメニューカメラで撮影された可能性があるため)
|
||||
-----------------------------------------------------------------------*/
|
||||
void SearchPicture();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 検索結果の写真枚数を取得する
|
||||
@return 見つかった写真枚数
|
||||
@details
|
||||
1枚も写真が見つからなかった場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetResultNum();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを取得する
|
||||
@param[in] nIndex 取得するデータのインデックス [0, GetResultNum())
|
||||
@return タイトルユニークID
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetTitleUniqueId(int nIndex);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真のパスを取得する
|
||||
@param[out] pPath パスを格納するバッファ(ヌル不可)
|
||||
@param[in] nSize パスを格納するバッファのサイズ(文字数単位)
|
||||
@param[in] nIndex 取得するデータのインデックス [0, GetResultNum())
|
||||
@details
|
||||
pPathとnSizeはc_nMaxPathSize以上のバッファを指定する必要があります。
|
||||
バッファが不足している場合はアサートが発生します。
|
||||
-----------------------------------------------------------------------*/
|
||||
void GetPath(wchar_t* pPath, int nSize, int nIndex);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真の種類を取得する
|
||||
@param[in] nIndex 取得するデータのインデックス [0, GetResultNum())
|
||||
@return 写真の種類
|
||||
-----------------------------------------------------------------------*/
|
||||
imgio::ImageKind GetImageKind(int nIndex);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影日時情報を取得する
|
||||
@param[in] nIndex 取得するデータのインデックス [0, GetResultNum())
|
||||
@return 撮影日時情報
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::fnd::DateTime GetDateTime(int nIndex);
|
||||
|
||||
|
||||
} // end of namespace search
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_ENUMERATOR_H_
|
||||
@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageIOTypes.h
|
||||
|
||||
定義
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_IO_TYPES_H_
|
||||
#define IMAGE_IO_TYPES_H_
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace imgio {
|
||||
|
||||
|
||||
//! ファイルパスの格納に必要なバッファサイズ(文字数単位)
|
||||
static const int c_nMaxPathSize = 44;
|
||||
|
||||
//! 映像データの種類を示す列挙型
|
||||
enum ImageKind {
|
||||
ImageKindJpeg = 0, //!< JPEGファイルのデータ
|
||||
ImageKindMp, //!< MPファイルのデータ
|
||||
|
||||
ImageKindNum //!< 列挙型の要素数(使用しません)
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace imgio
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_IO_TYPES_H_
|
||||
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: ImageIOUtility.h
|
||||
|
||||
ユーティリティ
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef IMAGE_IO_UTILITY_H_
|
||||
#define IMAGE_IO_UTILITY_H_
|
||||
|
||||
|
||||
#include <nn/assert.h>
|
||||
#include <nn/types.h>
|
||||
#include "../Core/ImageDbResult.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
namespace util {
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 管理されている写真枚数を取得する
|
||||
@return 写真枚数
|
||||
@details
|
||||
SDカードが認識できていない場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRegisteredPictureNum();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真の残り撮影枚数を見積もる
|
||||
@return 写真の残り撮影枚数
|
||||
@details
|
||||
残り空き容量から残り撮影枚数を見積もります。
|
||||
この見積もり枚数はニンテンドー3DSカメラと同じです。
|
||||
SDカードが認識できていない場合はゼロを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
int EstimateRemainPictureNum();
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真のタイトルユニークIDが指定のIDと同じかチェックする
|
||||
@param[in] pPath 写真のパス
|
||||
@param[in] nUId タイトルユニークID
|
||||
@return 同じ場合はtrue
|
||||
@details
|
||||
pPathはJpeg/MpSaver、写真選択アプレットで取得したパスを指定します。
|
||||
写真が読み込めないなどの理由で確認できない場合はfalseを返します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
bool IsSamePictureTitleUniqueId(const wchar_t* pPath, u32 nUId);
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 写真を削除する
|
||||
@param[in] pPath 写真のパス
|
||||
@param[in] nUId タイトルユニークID
|
||||
@return 結果
|
||||
@details
|
||||
pPathはJpeg/MpSaver、写真選択アプレットで取得したパスを指定します。
|
||||
nUIdにはアプリのタイトルユニークIDを指定します。
|
||||
このIDと写真を比較し一致した(このアプリが撮影した写真と判断した)場合のみ、
|
||||
写真の削除が行われます。
|
||||
不一致の場合はResultErrorPermissionDeniedを返し削除に失敗します。
|
||||
*---------------------------------------------------------------------------*/
|
||||
Result DeletePicture(const wchar_t* pPath, u32 nUId);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真を集めてImageDb管理の写真にする
|
||||
@return 処理結果
|
||||
@details
|
||||
SDカードにある ImageDb に管理されていない写真を探して ImageDb に登録します。<BR>
|
||||
また、登録した情報を管理ファイルへ反映させます。<BR>
|
||||
PC上でSDカードに直接写真を追加削除された場合などに、それらの写真を管理す
|
||||
るためには、この関数を呼び出す必要があります。<BR>
|
||||
<BR>
|
||||
扱う画像のパスについては「ImageDb プログラミングマニュアル」をご確認くだ
|
||||
さい。<BR>
|
||||
ただし、以下の点にご注意ください。<BR>
|
||||
・MP ファイルに付属する同一名の JPG ファイルは無視される<BR>
|
||||
・MP ファイルは付属の JPG ファイルがなくても検索は可能<BR>
|
||||
<BR>
|
||||
この関数はSDカードの写真枚数によっては処理にかなりの時間が掛かります。<BR>
|
||||
電源ボタン対応などのために処理を中断する場合は、この関数を呼び出した
|
||||
スレッドとは別のスレッドで StopCollect() を使用してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result CollectPicture();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 写真を集めの処理を中止する
|
||||
@details
|
||||
別スレッドから、CollectPicture() の処理中止を要求します。<BR>
|
||||
本関数を1度呼び出しただけでは中止を受け付けないことがあるため、
|
||||
CollectPicture()から処理が返ってくるまで、中止要求を行い続ける必要があ
|
||||
ります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void StopCollect();
|
||||
|
||||
|
||||
} // end of namespace util
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // IMAGE_IO_UTILITY_H_
|
||||
@ -0,0 +1,637 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: JpegMpLoader.h
|
||||
|
||||
SDカードにあるJPEG/MPファイルを読み込み、デコードした結果を返します。
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef JPEG_MP_LOADER_H_
|
||||
#define JPEG_MP_LOADER_H_
|
||||
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include <nn/jpeg.h>
|
||||
#include "../Core/ImageDbResult.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEG/MPベース読み込みクラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(push, 4)
|
||||
class JpegMpBaseLoader
|
||||
{
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegMpBaseLoader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegMpBaseLoader();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Load()を呼び出す前に設定しておく情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開したユーザーメーカーノートを格納するバッファを取得する
|
||||
@return バッファ
|
||||
-----------------------------------------------------------------------*/
|
||||
void* GetUserMakerNoteBuffer() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開したユーザーメーカーノートを格納するバッファのサイズを取得する
|
||||
@return バッファサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetUserMakerNoteBufferSize() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開したユーザーメーカーノートを格納するバッファを設定する
|
||||
@param[in] pBuf バッファ
|
||||
@param[in] nSize バッファサイズ(バイト単位)
|
||||
@details
|
||||
バッファのアドレスは4バイトにアライメントされている必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetUserMakerNoteBuffer(void* pBuf, std::size_t nSize);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Load()呼び出し成功後に取得できる情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デコードした撮影日時情報を取得する
|
||||
@param[out] rDateTime 撮影日時
|
||||
@return デコードに成功していない場合はfalse
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetDateTime(nn::fnd::DateTime& rDateTime) const;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
アプリケーション用のメーカーノート
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アプリケーション用のメーカーノートのデータサイズを取得する
|
||||
@return データサイズ(バイト単位)
|
||||
@details
|
||||
デコードにより取り出したメーカーノートの実際のデータサイズです。
|
||||
データ自体はSetUserMakerNoteBuffer()で指定したバッファに書き込まれています。
|
||||
バッファが設定されていない、設定されていたがバッファサイズが不足して
|
||||
取り出されなかった場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetUserMakerNoteDataSize() const;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
システムメーカーノート
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートが存在するかチェックする
|
||||
@return 存在する場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsExistSysMakerNote() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのデータサイズを取得する
|
||||
@return データサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static std::size_t GetSysMakerNoteDataSize();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートを取得する
|
||||
@return システムメーカーノート
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetSysMakerNoteData() const;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
タイトルユニークID
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを取得する
|
||||
@return タイトルユニークID
|
||||
@details
|
||||
タイトルユニークIDとはアプリケーションが持つ20bitのユニークIDです。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetTitleUniqueId() const;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
属性
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief スクリーンショットフラグを取得する
|
||||
@retval true スクリーンショットのデータ
|
||||
@retval false スクリーンショット以外のデータ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetScreenshotFlag() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 焦点調整範囲表示フラグを取得する
|
||||
@return 焦点調整範囲表示フラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetAdjustablePictureFlag() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 顔が含まれている写真かチェックする
|
||||
@return 顔が含まれているならtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsExistFace() const;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
本体ID
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidShotBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDを取得する
|
||||
@return 撮影した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetShotBodyId() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidSendBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDを取得する
|
||||
@return 送信した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSendBodyId() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidReceiveBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDを取得する
|
||||
@return 受信した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetReceiveBodyId() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidEditorBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDを取得する
|
||||
@return 最後に編集した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetEditorBodyId() const;
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
その他
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 画像のサイズを求める
|
||||
@param[in] nWidth 画像の幅(ピクセル単位)
|
||||
@param[in] nHeight 画像の高さ(ピクセル単位)
|
||||
@param[in] eFormat 画像のピクセルフォーマット
|
||||
@return 画像サイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static std::size_t ComputeImageSize(
|
||||
int nWidth, int nHeight, nn::jpeg::CTR::PixelFormat eFormat);
|
||||
|
||||
protected:
|
||||
void SetDateTime(const nn::fnd::DateTime& rDateTime);
|
||||
void ResetDateTime();
|
||||
|
||||
bool SetSysMakerNoteData(const void* pNote, std::size_t nSize);
|
||||
|
||||
void SetUserMakerNoteDataSize(std::size_t nSize);
|
||||
|
||||
void SetScreenshotFlag(bool bFlag);
|
||||
void SetAdjustablePictureFlag(bool bFlag);
|
||||
|
||||
void SetShotBodyId(u32 nBodyId);
|
||||
void ResetShotBodyId();
|
||||
|
||||
void SetSendBodyId(u32 nBodyId);
|
||||
void ResetSendBodyId();
|
||||
|
||||
void SetReceiveBodyId(u32 nBodyId);
|
||||
void ResetReceiveBodyId();
|
||||
|
||||
void SetEditorBodyId(u32 nBodyId);
|
||||
void ResetEditorBodyId();
|
||||
|
||||
private:
|
||||
bool GetHandleFlag(int nHandleType) const;
|
||||
void SetHandleFlag(int nHandleType, bool bFlag);
|
||||
|
||||
bool IsValidBodyId(int nIdType) const;
|
||||
u32 GetBodyId(int nIdType) const;
|
||||
void SetBodyId(int nIdType, u32 nBodyId);
|
||||
void ResetBodyId(int nIdType);
|
||||
|
||||
private:
|
||||
void* m_pUserMakerNoteBuf;
|
||||
std::size_t m_pUserMakerNoteBufSize;
|
||||
nn::fnd::DateTime m_nDateTime;
|
||||
bool m_bValidDateTime;
|
||||
NN_PADDING3;
|
||||
std::size_t m_nUserMakerNoteDataSize;
|
||||
void* m_pSysMakerNoteData;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEG読み込みクラス
|
||||
@details
|
||||
JPEGを読み込むには最低限以下の関数を呼び出す必要があります。<BR>
|
||||
SetFilePath()<BR>
|
||||
SetBuffer()<BR>
|
||||
SetFormat()<BR>
|
||||
Load()
|
||||
*---------------------------------------------------------------------------*/
|
||||
class JpegLoader : public JpegMpBaseLoader, private nn::util::NonCopyable<JpegLoader>
|
||||
{
|
||||
public:
|
||||
//! 展開画像のピクセルフォーマットのデフォルト値
|
||||
static const nn::jpeg::CTR::PixelFormat c_eDefaultRawFormat = nn::jpeg::CTR::PIXEL_FORMAT_CTR_RGB565;
|
||||
//! サムネイル読み込みモードのデフォルト値
|
||||
static const bool c_nDefaultThumbnailMode = false;
|
||||
//! 展開した画像を格納するバッファの幅のデフォルト値
|
||||
static const int c_nDefaultOutputWidth = 0;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegLoader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegLoader();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGファイルを読み込む
|
||||
@return 結果
|
||||
@details
|
||||
現在の設定されている内容でJPEG画像を読み込んで展開します。<BR>
|
||||
呼び出し前に各種設定を行っておいてください。<BR>
|
||||
設定が不正だった場合はResultErrorInvalidParamが返ってきます。<BR>
|
||||
本関数を呼び出すと内部で一時的に最大で 400KB 程のメモリが消費されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result Load();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Load()を呼び出す前に設定しておく情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込むJPEGファイルのパスを取得する
|
||||
@return ファイルパス
|
||||
-----------------------------------------------------------------------*/
|
||||
const wchar_t* GetFilePath() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込むJPEGファイルのパスを設定する
|
||||
@param[in] pPath ファイルパス
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetFilePath(const wchar_t* pPath);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開画像のピクセルフォーマットを取得する
|
||||
@return ピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::jpeg::CTR::PixelFormat GetFormat() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開画像のピクセルフォーマットを設定する
|
||||
@param[in] eFormat ピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetFormat(nn::jpeg::CTR::PixelFormat eFormat);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファの幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetOutputWidth();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファの幅を設定する
|
||||
@param[in] nWidth 幅(ピクセル単位)
|
||||
@details
|
||||
この幅はデコードのバッファの横幅を指定するもので、この値を指定すること
|
||||
で、例えば64×64の画像を256×256のバッファの左上に展開するといったこと
|
||||
が可能になります。この値が画像の幅よりも小さい場合は、ビッチリと詰まっ
|
||||
た状態で画像がデコードされます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetOutputWidth(int nWidth);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイル読み込みモードか調べる
|
||||
@retval true サムネイル読み込みモード
|
||||
@retval false 画像読み込みモード
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsThumbnailMode() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイル読み込みモードを設定する
|
||||
@param[in] bThumbMode サムネイル読み込みモード
|
||||
@details
|
||||
bThumbModeにtrueを指定すると、Load()時にサムネイル画像が読み込まれます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetThumbnailMode(bool bThumbMode);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファを取得する
|
||||
@return バッファ
|
||||
-----------------------------------------------------------------------*/
|
||||
void* GetBuffer() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファのサイズを取得する
|
||||
@return バッファサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetBufferSize() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファを設定する
|
||||
@param[in] pBuf バッファ
|
||||
@param[in] nSize バッファサイズ(バイト単位)
|
||||
@details
|
||||
バッファのアドレスは4バイトにアライメントされている必要があります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetBuffer(void* pBuf, std::size_t nSize);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Load()を呼び出す成功後に取得できる情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ画像の幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
@details
|
||||
縮小デコードが働く場合は縮小後の幅となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawWidth() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ画像の高さを取得する
|
||||
@return 高さ(ピクセル単位)
|
||||
@details
|
||||
縮小デコードが働く場合は縮小後の高さとなります。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawHeight() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ画像のデータサイズを取得する
|
||||
@return データサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetRawDataSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 縮小デコードの影響を受けない実画像の幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRealWidth() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 縮小デコードの影響を受けない実画像の高さを取得する
|
||||
@return 高さ(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRealHeight() const;
|
||||
|
||||
private:
|
||||
void ResetLoaded();
|
||||
bool IsLoaded() const;
|
||||
|
||||
Result ValidateParam() const;
|
||||
|
||||
private:
|
||||
const wchar_t* m_pFilePath;
|
||||
int m_nOutputWidth;
|
||||
nn::jpeg::CTR::PixelFormat m_eFormat;
|
||||
bool m_bThumbMode;
|
||||
NN_PADDING2;
|
||||
|
||||
void* m_pBuf;
|
||||
std::size_t m_nBufSize;
|
||||
|
||||
int m_nRawWidth;
|
||||
int m_nRawHeight;
|
||||
std::size_t m_nRawDataSize;
|
||||
int m_nRealWidth;
|
||||
int m_nRealHeight;
|
||||
};
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief MP読み込みクラス
|
||||
@details
|
||||
MPを読み込むには最低限以下の関数を呼び出す必要があります。<BR>
|
||||
SetFilePath()<BR>
|
||||
SetBuffer()<BR>
|
||||
SetFormat()<BR>
|
||||
Load()<BR>
|
||||
|
||||
立体画像として表示する際、通常は GetOffsetH() の値に応じて画像を左右にずら
|
||||
して表示してください。
|
||||
*---------------------------------------------------------------------------*/
|
||||
class MpLoader : public JpegMpBaseLoader, private nn::util::NonCopyable<MpLoader>
|
||||
{
|
||||
public:
|
||||
//! 展開画像のピクセルフォーマットのデフォルト値
|
||||
static const nn::jpeg::CTR::PixelFormat c_eDefaultRawFormat = nn::jpeg::CTR::PIXEL_FORMAT_CTR_RGB565;
|
||||
//! サムネイル読み込みモードのデフォルト値
|
||||
static const bool c_nDefaultThumbnailMode = false;
|
||||
//! 展開した画像を格納するバッファの幅のデフォルト値
|
||||
static const int c_nDefaultOutputWidth = 0;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
MpLoader();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~MpLoader();
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルを読み込む
|
||||
@return 結果
|
||||
@details
|
||||
現在の設定されている内容でMP画像を読み込んで展開します。<BR>
|
||||
呼び出し前に各種設定を行っておいてください。<BR>
|
||||
設定が不正だった場合はResultErrorInvalidParamが返ってきます。<BR>
|
||||
本関数を呼び出すと内部で一時的に最大で 400KB 程のメモリが消費されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result Load();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Load()を呼び出す前に設定しておく情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込むMPファイルのパスを取得する
|
||||
@return ファイルパス
|
||||
-----------------------------------------------------------------------*/
|
||||
const wchar_t* GetFilePath() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込むMPファイルのパスを設定する
|
||||
@param[in] pPath ファイルパス
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetFilePath(const wchar_t* pPath);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開画像のピクセルフォーマットを取得する
|
||||
@return ピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::jpeg::CTR::PixelFormat GetFormat() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開画像のピクセルフォーマットを設定する
|
||||
@param[in] eFormat ピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetFormat(nn::jpeg::CTR::PixelFormat eFormat);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファの幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetOutputWidth();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファの幅を設定する
|
||||
@param[in] nWidth 幅(ピクセル単位)
|
||||
@details
|
||||
この幅はデコードのバッファの横幅を指定するもので、この値を指定すること
|
||||
で、例えば64×64の画像を256×256のバッファの左上に展開するといったこと
|
||||
が可能になります。この値が画像の幅よりも小さい場合は、ビッチリと詰まっ
|
||||
た状態で画像がデコードされます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetOutputWidth(int nWidth);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイル読み込みモードか調べる
|
||||
@retval true サムネイル読み込みモード
|
||||
@retval false 画像読み込みモード
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsThumbnailMode() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief サムネイル読み込みモードを設定する
|
||||
@param[in] bThumbMode サムネイル読み込みモード
|
||||
@details
|
||||
bThumbModeにtrueを指定すると、Load()時にサムネイル画像が読み込まれます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetThumbnailMode(bool bThumbMode);
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した左側の画像を格納するバッファを取得する
|
||||
@return バッファ
|
||||
-----------------------------------------------------------------------*/
|
||||
void* GetBufferL();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した右側の画像を格納するバッファを取得する
|
||||
@return バッファ
|
||||
-----------------------------------------------------------------------*/
|
||||
void* GetBufferR();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファのサイズを取得する
|
||||
@return バッファサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetBufferSize() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 展開した画像を格納するバッファを設定する
|
||||
@param[in] pBufL 左側のバッファ(ヌル不可)
|
||||
@param[in] pBufR 右側のバッファ(ヌル可)
|
||||
@param[in] nSize バッファサイズ(バイト単位)
|
||||
@details
|
||||
バッファのアドレスは4バイトにアライメントされている必要があります。<BR>
|
||||
pBufRにヌルを指定することで、左側の画像だけを取得することが出来ます。<BR>
|
||||
サムネイル画像はpBufRにも左側の画像が格納されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetBuffer(void* pBufL, void* pBufR, std::size_t nSize);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Load()呼び出し成功後に取得できる情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ画像の幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
@details
|
||||
縮小デコードが働く場合は縮小後の幅となります。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawWidth() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ画像の高さを取得する
|
||||
@return 高さ(ピクセル単位)
|
||||
@details
|
||||
縮小デコードが働く場合は縮小後の高さとなります。
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawHeight() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 読み込んだ画像のデータサイズを取得する
|
||||
@return データサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetRawDataSize() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 縮小デコードの影響を受けない実画像の幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRealWidth() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 縮小デコードの影響を受けない実画像の高さを取得する
|
||||
@return 高さ(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRealHeight() const;
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 水平オフセット値を取得する
|
||||
@return 水平オフセット値(ピクセル単位)
|
||||
@details
|
||||
値が 0.0f の時は左と右の画像を同じ位置に表示します。<BR>
|
||||
値が 1.0f の時は 左画像を左に(縮小デコードの影響を受けない実画像の幅に
|
||||
対して)1ピクセル、右画像を右に1ピクセル移動して表示します。<BR>
|
||||
画面上の表示位置は表示する大きさに合わせたスケールがかかるようにしてく
|
||||
ださい。<BR>
|
||||
この値は GetAdjustablePictureFlag() が true を返すときのみ使用し、false
|
||||
のときは 0.0f として扱ってください。
|
||||
-----------------------------------------------------------------------*/
|
||||
f32 GetOffsetH() const;
|
||||
|
||||
private:
|
||||
void ResetLoaded();
|
||||
bool IsLoaded() const;
|
||||
|
||||
Result ValidateParam() const;
|
||||
|
||||
private:
|
||||
const wchar_t* m_pFilePath;
|
||||
int m_nOutputWidth;
|
||||
nn::jpeg::CTR::PixelFormat m_eFormat;
|
||||
bool m_bThumbMode;
|
||||
NN_PADDING2;
|
||||
|
||||
void* m_pBufL;
|
||||
void* m_pBufR;
|
||||
std::size_t m_nBufSize;
|
||||
|
||||
int m_nRawWidth;
|
||||
int m_nRawHeight;
|
||||
std::size_t m_nRawDataSize;
|
||||
int m_nRealWidth;
|
||||
int m_nRealHeight;
|
||||
f32 m_fOfstH;
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // JPEG_MP_LOADER_H_
|
||||
@ -0,0 +1,604 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: JpegMpSaver.h
|
||||
|
||||
生画像データを受け取ると、JPEG/MPにエンコードし、SDカードへ保存します。
|
||||
保存された画像はニンテンドー3DSカメラで管理されます。
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef JPEG_MP_SAVER_H_
|
||||
#define JPEG_MP_SAVER_H_
|
||||
|
||||
#include <nn/types.h>
|
||||
#include <nn/util.h>
|
||||
#include <nn/jpeg.h>
|
||||
#include "ImageIOTypes.h"
|
||||
#include "../Core/ImageDbResult.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEG/MPベース保存クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
class JpegMpBaseSaver
|
||||
{
|
||||
public:
|
||||
//! スクリーンショットフラグのデフォルト値
|
||||
static const bool c_bDefaultScreenshotFlag = false;
|
||||
//! 配布許可フラグのデフォルト値
|
||||
static const bool c_bDefaultPermitDistributeFlag = true;
|
||||
//! 焦点調整範囲表示フラグのデフォルト値
|
||||
static const bool c_bDefaultAdjustablePictureFlag = false;
|
||||
//! 無効な本体ID
|
||||
static const u32 c_nInvalidId = 0;
|
||||
//! 撮影した本体IDの有効状態のデフォルト値
|
||||
static const bool c_bDefaultValidShotId = true;
|
||||
//! 送信した本体IDの有効状態のデフォルト値
|
||||
static const bool c_bDefaultValidSendId = false;
|
||||
//! 受信した本体IDの有効状態のデフォルト値
|
||||
static const bool c_bDefaultValidReceiveId = false;
|
||||
//! 最後に編集した本体IDの有効状態のデフォルト値
|
||||
static const bool c_bDefaultValidEditorId = false;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegMpBaseSaver();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegMpBaseSaver();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Save()を呼び出す前に設定しておく情報
|
||||
=======================================================================*/
|
||||
/*-----------------------------------------------------------------------
|
||||
アプリケーション用のメーカーノート
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アプリケーション用のメーカーノートのデータを取得する
|
||||
@return データ
|
||||
@details
|
||||
設定されていない場合はヌルを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetUserMakerNoteData() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アプリケーション用のメーカーノートのデータサイズを取得する
|
||||
@return データサイズ(バイト単位)
|
||||
@details
|
||||
設定されていない場合はゼロを返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
std::size_t GetUserMakerNoteDataSize() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief アプリケーション用のメーカーノートを設定する
|
||||
@param[in] pData データ
|
||||
@param[in] nSize データサイズ(バイト単位)
|
||||
@details
|
||||
pDataにヌル、またはnSizeにゼロを指定すると未設定の状態になります。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetUserMakerNote(const void* pData, std::size_t nSize);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
システムメーカーノート
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートのデータサイズを取得する
|
||||
@return データサイズ(バイト単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
static std::size_t GetSysMakerNoteDataSize();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートを取得する
|
||||
@return システムメーカーノート
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetSysMakerNoteData() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief システムメーカーノートを設定する
|
||||
@param[in] pNote システムメーカーノート
|
||||
@param[in] nSize システムメーカーノートのデータサイズ
|
||||
@return 設定に成功した場合はtrue
|
||||
@details
|
||||
タイトルユニークIDや各種フラグなど、設定された情報はすべて指定された
|
||||
システムメーカーノートの値に上書きされます。
|
||||
-----------------------------------------------------------------------*/
|
||||
bool SetSysMakerNoteData(const void* pNote, std::size_t nSize);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
タイトルユニークID
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを取得する
|
||||
@return タイトルユニークID
|
||||
@details
|
||||
タイトルユニークIDとはアプリケーションが持つ20bitのユニークIDです。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetTitleUniqueId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief タイトルユニークIDを設定する
|
||||
@param[in] nUId タイトルユニークID
|
||||
@return 設定に成功した場合はtrue
|
||||
@details
|
||||
タイトルユニークIDとはアプリケーションが持つ20bitのユニークIDです。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetTitleUniqueId(u32 nUId);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
属性
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief スクリーンショットフラグを取得する
|
||||
@retval true スクリーンショットのデータ
|
||||
@retval false スクリーンショット以外のデータ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetScreenshotFlag() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief スクリーンショットフラグを設定する
|
||||
@param[in] bFlag スクリーンショットフラグ
|
||||
@details
|
||||
スクリーンショットのためのフラグです。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetScreenshotFlag(bool bFlag);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 配布許可フラグを取得する
|
||||
@retval true 配布を許可する
|
||||
@retval false 配布を禁止する
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetPermitDistributeFlag() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 配布許可フラグを設定する
|
||||
@param[in] bFlag 配布許可フラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetPermitDistributeFlag(bool bFlag);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 焦点調整範囲表示フラグを取得する
|
||||
@return 焦点調整範囲表示フラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetAdjustablePictureFlag() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 焦点調整範囲表示フラグを設定する
|
||||
@param[in] bFlag 焦点調整範囲表示フラグ
|
||||
@details
|
||||
このフラグが立っている画像は、ニンテンドー3DSカメラのブラウズで表示され
|
||||
るとき、横幅を基準に焦点調整ができる範囲が表示されます(平面画像でも表示
|
||||
範囲は同一)。<BR>
|
||||
ただし画像サイズが 400x240~1024x768 の場合のみ設定できます。<BR>
|
||||
このフラグが立っていない画像は、画像の全体がULCD画面の中に収まるように
|
||||
表示され、焦点調整はできません。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetAdjustablePictureFlag(bool bFlag);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
本体ID
|
||||
-----------------------------------------------------------------------*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidShotBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDを取得する
|
||||
@return 撮影した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
デフォルトでこのCTRの本体IDが設定されています。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetShotBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDを設定する
|
||||
@param[in] nBodyId 本体ID
|
||||
@details
|
||||
既存の画像の場合は、その画像に含まれる撮影した本体IDを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetShotBodyId(u32 nBodyId);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDを自分の本体IDに設定する
|
||||
@details
|
||||
既存の画像の場合は、その画像に含まれる撮影した本体IDを、SetShotBodyId()で
|
||||
指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetShotBodyIdByOwn();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 撮影した本体IDを無効状態にリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetShotBodyId();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidSendBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDを取得する
|
||||
@return 送信した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetSendBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDを設定する
|
||||
@param[in] nBodyId 本体ID
|
||||
@details
|
||||
アプリ内で送受信した画像の場合は、適切なIDを指定してください。
|
||||
そのほかの場合は初期値か、既存の画像のIDを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetSendBodyId(u32 nBodyId);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDを自分の本体IDに設定する
|
||||
@details
|
||||
アプリ内で送受信した画像の場合は、適切なIDを指定してください。
|
||||
そのほかの場合は初期値か、既存の画像のIDを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetSendBodyIdByOwn();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 送信した本体IDを無効状態にリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetSendBodyId();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidReceiveBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDを取得する
|
||||
@return 受信した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetReceiveBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDを設定する
|
||||
@param[in] nBodyId 本体ID
|
||||
@details
|
||||
アプリ内で送受信した画像の場合は、適切なIDを指定してください。
|
||||
そのほかの場合は初期値か、既存の画像のIDを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetReceiveBodyId(u32 nBodyId);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDを自分の本体IDに設定する
|
||||
@details
|
||||
アプリ内で送受信した画像の場合は、適切なIDを指定してください。
|
||||
そのほかの場合は初期値か、既存の画像のIDを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetReceiveBodyIdByOwn();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 受信した本体IDを無効状態にリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetReceiveBodyId();
|
||||
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDが有効かチェックする
|
||||
@return 有効な場合はtrue
|
||||
-----------------------------------------------------------------------*/
|
||||
bool IsValidEditorBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDを取得する
|
||||
@return 最後に編集した本体ID
|
||||
@details
|
||||
無効な場合の戻り値は不定です。
|
||||
-----------------------------------------------------------------------*/
|
||||
u32 GetEditorBodyId() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDを設定する
|
||||
@param[in] nBodyId 本体ID
|
||||
@details
|
||||
既存の画像を加工などを行って保存する場合は、このCTRの本体IDを指定するか、
|
||||
SetEditorBodyIdByOwn()で設定を行ってください。
|
||||
そのほかの場合は初期値か、既存の画像のIDを指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetEditorBodyId(u32 nBodyId);
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDを自分の本体IDに設定する
|
||||
@details
|
||||
既存の画像の場合は、その画像に含まれる最後に編集した本体IDを、
|
||||
SetEditorBodyId()で指定してください。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetEditorBodyIdByOwn();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 最後に編集した本体IDを無効状態にリセットする
|
||||
-----------------------------------------------------------------------*/
|
||||
void ResetEditorBodyId();
|
||||
|
||||
|
||||
/* 削除予定 */
|
||||
void SetPermitUploadFlag(bool ) { }
|
||||
void SetPermitEditDistributeFlag(bool ) { }
|
||||
void SetPermitSecondDistributeFlag(bool ) { }
|
||||
|
||||
protected:
|
||||
bool IsValidTitleUniqueId() const;
|
||||
|
||||
bool GetHandleFlag(int nHandleType) const;
|
||||
void SetHandleFlag(int nHandleType, bool bFlag);
|
||||
|
||||
bool IsValidBodyId(int nIdType) const;
|
||||
u32 GetBodyId(int nIdType) const;
|
||||
void SetBodyId(int nIdType, u32 nBodyId);
|
||||
void ResetBodyId(int nIdType);
|
||||
|
||||
protected:
|
||||
const void* m_pUserMakerNoteData;
|
||||
std::size_t m_nUserMakerNoteDataSize;
|
||||
void* m_pSysMakerNoteData;
|
||||
bool m_bValidTitleUniqueId;
|
||||
NN_PADDING3;
|
||||
};
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief JPEG保存クラス
|
||||
@details
|
||||
JPEGを保存するには最低限以下の関数を呼び出す必要があります。<BR>
|
||||
SetRaw()<BR>
|
||||
SetTitleUniqueId()<BR>
|
||||
Save()
|
||||
*---------------------------------------------------------------------------*/
|
||||
class JpegSaver : public JpegMpBaseSaver, private nn::util::NonCopyable<JpegSaver>
|
||||
{
|
||||
public:
|
||||
//! JPEGの品質のデフォルト値
|
||||
static const int c_nDefaultJpegQuality = 80;
|
||||
//! JPEGのサンプリングフォーマットのデフォルト値
|
||||
static const nn::jpeg::CTR::PixelSampling c_eDefaultJpegFormat = nn::jpeg::CTR::PIXEL_SAMPLING_YUV422;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegSaver();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegSaver();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGファイルとして保存する
|
||||
@return 結果
|
||||
@details
|
||||
現在の設定されている内容で画像をJPEGに変換して保存します。<BR>
|
||||
呼び出し前に各種設定を行っておいてください。<BR>
|
||||
設定が不正だった場合はResultErrorInvalidParamが返ってきます。<BR>
|
||||
本関数を呼び出すと内部で一時的に 200KB 程のメモリが消費されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result Save();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Save()を呼び出す前に設定しておく情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGの品質を取得する
|
||||
@return 品質 [1, 100]
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetJpegQuality() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGの品質を設定する
|
||||
@param[in] nQuality 品質 [1, 100]
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetJpegQuality(int nQuality);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGのサンプリングフォーマットを取得する
|
||||
@return サンプリングフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::jpeg::CTR::PixelSampling GetJpegFormat() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGのサンプリングフォーマットを設定する
|
||||
@param[in] eFormat サンプリングフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetJpegFormat(nn::jpeg::CTR::PixelSampling eFormat);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像データを取得する
|
||||
@return 画像データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetRawData() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像の幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawWidth() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像の高さを取得する
|
||||
@return 高さ(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawHeight() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像のピクセルフォーマットを取得する
|
||||
@return ピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::jpeg::CTR::PixelFormat GetRawFormat() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像を設定する
|
||||
@param[in] pData 画像データ
|
||||
@param[in] nWidth 画像の幅(ピクセル単位)
|
||||
@param[in] nHeight 画像の高さ(ピクセル単位)
|
||||
@param[in] eFormat 画像のピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetRaw(
|
||||
const void* pData, int nWidth, int nHeight,
|
||||
nn::jpeg::CTR::PixelFormat eFormat);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Save()呼び出し成功後に取得できる情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存したJPEGのファイルパスを取得する
|
||||
@return ファイルパス
|
||||
@details
|
||||
保存していない、出来なかった場合などは空文字列を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
const wchar_t* GetSavedFilePath() const;
|
||||
|
||||
private:
|
||||
Result ValidateParam() const;
|
||||
void SetFilePathToVirtual(const wchar_t* pPath);
|
||||
|
||||
private:
|
||||
int m_nJpegQuality;
|
||||
nn::jpeg::CTR::PixelSampling m_eJpegFormat;
|
||||
NN_PADDING3;
|
||||
|
||||
const void* m_pRawData;
|
||||
int m_nRawWidth;
|
||||
int m_nRawHeight;
|
||||
nn::jpeg::CTR::PixelFormat m_eRawFormat;
|
||||
NN_PADDING3;
|
||||
wchar_t* m_pFilePath;
|
||||
};
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief MP保存クラス
|
||||
@details
|
||||
MPを保存するには最低限以下の関数を呼び出す必要があります。<BR>
|
||||
SetRaw()<BR>
|
||||
SetTitleUniqueId()<BR>
|
||||
Save()
|
||||
*---------------------------------------------------------------------------*/
|
||||
class MpSaver : public JpegMpBaseSaver, private nn::util::NonCopyable<MpSaver>
|
||||
{
|
||||
public:
|
||||
//! JPEGの品質のデフォルト値
|
||||
static const int c_nDefaultJpegQuality = 80;
|
||||
//! JPEGのサンプリングフォーマットのデフォルト値
|
||||
static const nn::jpeg::CTR::PixelSampling c_eDefaultJpegFormat = nn::jpeg::CTR::PIXEL_SAMPLING_YUV422;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
MpSaver();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~MpSaver();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief MPファイルとして保存する
|
||||
@return 結果
|
||||
@details
|
||||
現在の設定されている内容で画像をMPに変換して保存します。<BR>
|
||||
呼び出し前に各種設定を行っておいてください。<BR>
|
||||
設定が不正だった場合はResultErrorInvalidParamが返ってきます。<BR>
|
||||
本関数を呼び出すと内部で一時的に 400KB 程のメモリが消費されます。
|
||||
-----------------------------------------------------------------------*/
|
||||
Result Save();
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Save()を呼び出す前に設定しておく情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGの品質を取得する
|
||||
@return 品質 [1, 100]
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetJpegQuality() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGの品質を設定する
|
||||
@param[in] nQuality 品質 [1, 100]
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetJpegQuality(int nQuality);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGのサンプリングフォーマットを取得する
|
||||
@return サンプリングフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::jpeg::CTR::PixelSampling GetJpegFormat() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief JPEGのサンプリングフォーマットを設定する
|
||||
@param[in] eFormat サンプリングフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetJpegFormat(nn::jpeg::CTR::PixelSampling eFormat);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する左側の画像データを取得する
|
||||
@return 画像データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetRawDataL() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する右側の画像データを取得する
|
||||
@return 画像データ
|
||||
-----------------------------------------------------------------------*/
|
||||
const void* GetRawDataR() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像の幅を取得する
|
||||
@return 幅(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawWidth() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像の高さを取得する
|
||||
@return 高さ(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
int GetRawHeight() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像のピクセルフォーマットを取得する
|
||||
@return ピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
nn::jpeg::CTR::PixelFormat GetRawFormat() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存する画像を設定する
|
||||
@param[in] pDataL 左側の画像データ
|
||||
@param[in] pDataR 右側の画像データ
|
||||
@param[in] nWidth 画像の幅(ピクセル単位)
|
||||
@param[in] nHeight 画像の高さ(ピクセル単位)
|
||||
@param[in] eFormat 画像のピクセルフォーマット
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetRaw(
|
||||
const void* pDataL, const void* pDataR,
|
||||
int nWidth, int nHeight, nn::jpeg::CTR::PixelFormat eFormat);
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 水平オフセット値を取得する
|
||||
@return 水平オフセット値(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
f32 GetOffsetH() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 水平オフセット値を設定する
|
||||
@param[in] fOfstH 水平オフセット値(ピクセル単位)
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetOffsetH(f32 fOfstH);
|
||||
|
||||
|
||||
/*=======================================================================
|
||||
Save()呼び出し成功後に取得できる情報
|
||||
=======================================================================*/
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief 保存したMPのファイルパスを取得する
|
||||
@return ファイルパス
|
||||
@details
|
||||
保存していない、出来なかった場合などは空文字列を返します。
|
||||
-----------------------------------------------------------------------*/
|
||||
const wchar_t* GetSavedFilePath() const;
|
||||
|
||||
private:
|
||||
Result ValidateParam() const;
|
||||
void SetFilePathToVirtual(const wchar_t* pPath);
|
||||
|
||||
private:
|
||||
int m_nJpegQuality;
|
||||
nn::jpeg::CTR::PixelSampling m_eJpegFormat;
|
||||
NN_PADDING3;
|
||||
|
||||
const void* m_pRawDataL;
|
||||
const void* m_pRawDataR;
|
||||
int m_nRawWidth;
|
||||
int m_nRawHeight;
|
||||
nn::jpeg::CTR::PixelFormat m_eRawFormat;
|
||||
NN_PADDING3;
|
||||
f32 m_fOfstH;
|
||||
wchar_t* m_pFilePath;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // JPEG_MP_SAVER_H_
|
||||
@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
Project: ImageDb
|
||||
File: JpegMpSaverEx.h
|
||||
|
||||
JpegMpSaverクラスに特殊用途向けの機能を追加したクラスです。
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef JPEG_MP_SAVER_EX_H_
|
||||
#define JPEG_MP_SAVER_EX_H_
|
||||
|
||||
#include "JpegMpSaver.h"
|
||||
|
||||
|
||||
namespace imgdb {
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 特殊用途向けJPEG保存クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
class JpegSaverEx : public JpegSaver, private nn::util::NonCopyable<JpegSaverEx>
|
||||
{
|
||||
public:
|
||||
// 各種パラメータのデフォルト値
|
||||
static const bool c_bDefaultMiiFlag = false;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
JpegSaverEx();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~JpegSaverEx();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief Mii特徴フラグを取得する
|
||||
@return Mii特徴フラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetMiiFlag() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief Mii特徴フラグを設定する
|
||||
@param[in] bMii Mii特徴フラグ
|
||||
@details
|
||||
bMiiにtrueを指定するとMii属性が付与され、PNOTEのスライドショーなどでMii
|
||||
の写真として扱われるようになったりします。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetMiiFlag(bool bMii);
|
||||
};
|
||||
|
||||
|
||||
/*!--------------------------------------------------------------------------*
|
||||
@brief 特殊用途向けMP保存クラス
|
||||
*---------------------------------------------------------------------------*/
|
||||
class MpSaverEx : public MpSaver, private nn::util::NonCopyable<MpSaverEx>
|
||||
{
|
||||
public:
|
||||
// 各種パラメータのデフォルト値
|
||||
static const bool c_bDefaultMiiFlag = false;
|
||||
|
||||
public:
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief コンストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
MpSaverEx();
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief デストラクタ
|
||||
-----------------------------------------------------------------------*/
|
||||
virtual ~MpSaverEx();
|
||||
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief Mii特徴フラグを取得する
|
||||
@return Mii特徴フラグ
|
||||
-----------------------------------------------------------------------*/
|
||||
bool GetMiiFlag() const;
|
||||
/*!----------------------------------------------------------------------
|
||||
@brief Mii特徴フラグを設定する
|
||||
@param[in] bMii Mii特徴フラグ
|
||||
@details
|
||||
bMiiにtrueを指定するとMii属性が付与され、PNOTEのスライドショーなどでMii
|
||||
の写真として扱われるようになったりします。
|
||||
-----------------------------------------------------------------------*/
|
||||
void SetMiiFlag(bool bMii);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end of namespace imgdb
|
||||
|
||||
#endif // JPEG_MP_SAVER_EX_H_
|
||||
Loading…
Reference in New Issue
Block a user