Merge remote-tracking branch 'qatar/master'
* qatar/master: libdirac/libschroedinger: Drop unnecessary symbol prefixes. cmdutils: check fread() return value Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
0489af478e
18
cmdutils.c
18
cmdutils.c
@ -809,6 +809,7 @@ int read_yesno(void)
|
||||
|
||||
int read_file(const char *filename, char **bufptr, size_t *size)
|
||||
{
|
||||
int ret;
|
||||
FILE *f = fopen(filename, "rb");
|
||||
|
||||
if (!f) {
|
||||
@ -824,11 +825,22 @@ int read_file(const char *filename, char **bufptr, size_t *size)
|
||||
fclose(f);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
fread(*bufptr, 1, *size, f);
|
||||
(*bufptr)[*size++] = '\0';
|
||||
ret = fread(*bufptr, 1, *size, f);
|
||||
if (ret < *size) {
|
||||
av_free(*bufptr);
|
||||
if (ferror(f)) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
|
||||
filename, strerror(errno));
|
||||
ret = AVERROR(errno);
|
||||
} else
|
||||
ret = AVERROR_EOF;
|
||||
} else {
|
||||
ret = 0;
|
||||
(*bufptr)[*size++] = '\0';
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
|
@ -35,7 +35,7 @@
|
||||
static const struct {
|
||||
enum PixelFormat ff_pix_fmt;
|
||||
dirac_chroma_t dirac_pix_fmt;
|
||||
} ffmpeg_dirac_pixel_format_map[] = {
|
||||
} dirac_pixel_format_map[] = {
|
||||
{ PIX_FMT_YUV420P, format420 },
|
||||
{ PIX_FMT_YUV422P, format422 },
|
||||
{ PIX_FMT_YUV444P, format444 },
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "libdirac_libschro.h"
|
||||
|
||||
static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
|
||||
static const DiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
|
||||
{ 640, 480, 24000, 1001},
|
||||
{ 176, 120, 15000, 1001},
|
||||
{ 176, 144, 25, 2 },
|
||||
@ -53,7 +53,7 @@ unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext)
|
||||
sizeof(ff_dirac_schro_video_format_info[0]);
|
||||
|
||||
for (idx = 1; idx < num_formats; ++idx) {
|
||||
const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
|
||||
const DiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
|
||||
if (avccontext->width == vf->width &&
|
||||
avccontext->height == vf->height) {
|
||||
ret_idx = idx;
|
||||
@ -65,22 +65,22 @@ unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext)
|
||||
return ret_idx;
|
||||
}
|
||||
|
||||
void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue)
|
||||
void ff_dirac_schro_queue_init(DiracSchroQueue *queue)
|
||||
{
|
||||
queue->p_head = queue->p_tail = NULL;
|
||||
queue->size = 0;
|
||||
}
|
||||
|
||||
void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
|
||||
void ff_dirac_schro_queue_free(DiracSchroQueue *queue,
|
||||
void (*free_func)(void *))
|
||||
{
|
||||
while (queue->p_head)
|
||||
free_func(ff_dirac_schro_queue_pop(queue));
|
||||
}
|
||||
|
||||
int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data)
|
||||
int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data)
|
||||
{
|
||||
FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
|
||||
DiracSchroQueueElement *p_new = av_mallocz(sizeof(DiracSchroQueueElement));
|
||||
|
||||
if (!p_new)
|
||||
return -1;
|
||||
@ -97,9 +97,9 @@ int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue)
|
||||
void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue)
|
||||
{
|
||||
FfmpegDiracSchroQueueElement *top = queue->p_head;
|
||||
DiracSchroQueueElement *top = queue->p_head;
|
||||
|
||||
if (top) {
|
||||
void *data = top->data;
|
||||
|
@ -33,7 +33,7 @@ typedef struct {
|
||||
uint16_t height;
|
||||
uint16_t frame_rate_num;
|
||||
uint16_t frame_rate_denom;
|
||||
} FfmpegDiracSchroVideoFormatInfo;
|
||||
} DiracSchroVideoFormatInfo;
|
||||
|
||||
/**
|
||||
* Returns the index into the Dirac Schro common video format info table
|
||||
@ -43,7 +43,7 @@ unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext);
|
||||
/**
|
||||
* contains a single encoded frame returned from Dirac or Schroedinger
|
||||
*/
|
||||
typedef struct FfmpegDiracSchroEncodedFrame {
|
||||
typedef struct DiracSchroEncodedFrame {
|
||||
/** encoded frame data */
|
||||
uint8_t *p_encbuf;
|
||||
|
||||
@ -55,51 +55,51 @@ typedef struct FfmpegDiracSchroEncodedFrame {
|
||||
|
||||
/** key frame flag. 1 : is key frame , 0 : in not key frame */
|
||||
uint16_t key_frame;
|
||||
} FfmpegDiracSchroEncodedFrame;
|
||||
} DiracSchroEncodedFrame;
|
||||
|
||||
/**
|
||||
* queue element
|
||||
*/
|
||||
typedef struct FfmpegDiracSchroQueueElement {
|
||||
typedef struct DiracSchroQueueElement {
|
||||
/** Data to be stored in queue*/
|
||||
void *data;
|
||||
/** Pointer to next element queue */
|
||||
struct FfmpegDiracSchroQueueElement *next;
|
||||
} FfmpegDiracSchroQueueElement;
|
||||
struct DiracSchroQueueElement *next;
|
||||
} DiracSchroQueueElement;
|
||||
|
||||
|
||||
/**
|
||||
* A simple queue implementation used in libdirac and libschroedinger
|
||||
*/
|
||||
typedef struct FfmpegDiracSchroQueue {
|
||||
typedef struct DiracSchroQueue {
|
||||
/** Pointer to head of queue */
|
||||
FfmpegDiracSchroQueueElement *p_head;
|
||||
DiracSchroQueueElement *p_head;
|
||||
/** Pointer to tail of queue */
|
||||
FfmpegDiracSchroQueueElement *p_tail;
|
||||
DiracSchroQueueElement *p_tail;
|
||||
/** Queue size*/
|
||||
int size;
|
||||
} FfmpegDiracSchroQueue;
|
||||
} DiracSchroQueue;
|
||||
|
||||
/**
|
||||
* Initialise the queue
|
||||
*/
|
||||
void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue);
|
||||
void ff_dirac_schro_queue_init(DiracSchroQueue *queue);
|
||||
|
||||
/**
|
||||
* Add an element to the end of the queue
|
||||
*/
|
||||
int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data);
|
||||
int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data);
|
||||
|
||||
/**
|
||||
* Return the first element in the queue
|
||||
*/
|
||||
void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue);
|
||||
void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue);
|
||||
|
||||
/**
|
||||
* Free the queue resources. free_func is a function supplied by the caller to
|
||||
* free any resources allocated by the caller. The data field of the queue
|
||||
* element is passed to it.
|
||||
*/
|
||||
void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
|
||||
void ff_dirac_schro_queue_free(DiracSchroQueue *queue,
|
||||
void (*free_func)(void *));
|
||||
#endif /* AVCODEC_LIBDIRAC_LIBSCHRO_H */
|
||||
|
@ -37,34 +37,34 @@
|
||||
#include <libdirac_decoder/dirac_parser.h>
|
||||
|
||||
/** contains a single frame returned from Dirac */
|
||||
typedef struct FfmpegDiracDecoderParams {
|
||||
typedef struct DiracDecoderParams {
|
||||
/** decoder handle */
|
||||
dirac_decoder_t* p_decoder;
|
||||
|
||||
/** buffer to hold decoded frame */
|
||||
unsigned char* p_out_frame_buf;
|
||||
} FfmpegDiracDecoderParams;
|
||||
} DiracDecoderParams;
|
||||
|
||||
|
||||
/**
|
||||
* returns FFmpeg chroma format
|
||||
*/
|
||||
static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt)
|
||||
static enum PixelFormat get_chroma_format(dirac_chroma_t dirac_pix_fmt)
|
||||
{
|
||||
int num_formats = sizeof(ffmpeg_dirac_pixel_format_map) /
|
||||
sizeof(ffmpeg_dirac_pixel_format_map[0]);
|
||||
int num_formats = sizeof(dirac_pixel_format_map) /
|
||||
sizeof(dirac_pixel_format_map[0]);
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < num_formats; ++idx)
|
||||
if (ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt)
|
||||
return ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt;
|
||||
if (dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt)
|
||||
return dirac_pixel_format_map[idx].ff_pix_fmt;
|
||||
return PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
static av_cold int libdirac_decode_init(AVCodecContext *avccontext)
|
||||
{
|
||||
|
||||
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data;
|
||||
DiracDecoderParams *p_dirac_params = avccontext->priv_data;
|
||||
p_dirac_params->p_decoder = dirac_decoder_init(avccontext->debug);
|
||||
|
||||
if (!p_dirac_params->p_decoder)
|
||||
@ -80,7 +80,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
|
||||
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data;
|
||||
DiracDecoderParams *p_dirac_params = avccontext->priv_data;
|
||||
AVPicture *picture = data;
|
||||
AVPicture pic;
|
||||
int pict_size;
|
||||
@ -117,7 +117,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
|
||||
avccontext->height = src_params->height;
|
||||
avccontext->width = src_params->width;
|
||||
|
||||
avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma);
|
||||
avccontext->pix_fmt = get_chroma_format(src_params->chroma);
|
||||
if (avccontext->pix_fmt == PIX_FMT_NONE) {
|
||||
av_log(avccontext, AV_LOG_ERROR,
|
||||
"Dirac chroma format %d not supported currently\n",
|
||||
@ -174,7 +174,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
|
||||
|
||||
static av_cold int libdirac_decode_close(AVCodecContext *avccontext)
|
||||
{
|
||||
FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data;
|
||||
DiracDecoderParams *p_dirac_params = avccontext->priv_data;
|
||||
dirac_decoder_close(p_dirac_params->p_decoder);
|
||||
|
||||
av_freep(&p_dirac_params->p_out_frame_buf);
|
||||
@ -198,7 +198,7 @@ AVCodec ff_libdirac_decoder = {
|
||||
.name = "libdirac",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_DIRAC,
|
||||
.priv_data_size = sizeof(FfmpegDiracDecoderParams),
|
||||
.priv_data_size = sizeof(DiracDecoderParams),
|
||||
.init = libdirac_decode_init,
|
||||
.close = libdirac_decode_close,
|
||||
.decode = libdirac_decode_frame,
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <libdirac_encoder/dirac_encoder.h>
|
||||
|
||||
/** Dirac encoder private data */
|
||||
typedef struct FfmpegDiracEncoderParams {
|
||||
typedef struct DiracEncoderParams {
|
||||
/** Dirac encoder context */
|
||||
dirac_encoder_context_t enc_ctx;
|
||||
|
||||
@ -61,27 +61,27 @@ typedef struct FfmpegDiracEncoderParams {
|
||||
int enc_buf_size;
|
||||
|
||||
/** queue storing encoded frames */
|
||||
FfmpegDiracSchroQueue enc_frame_queue;
|
||||
DiracSchroQueue enc_frame_queue;
|
||||
|
||||
/** end of sequence signalled by user, 0 - false, 1 - true */
|
||||
int eos_signalled;
|
||||
|
||||
/** end of sequence returned by encoder, 0 - false, 1 - true */
|
||||
int eos_pulled;
|
||||
} FfmpegDiracEncoderParams;
|
||||
} DiracEncoderParams;
|
||||
|
||||
/**
|
||||
* Works out Dirac-compatible chroma format.
|
||||
*/
|
||||
static dirac_chroma_t GetDiracChromaFormat(enum PixelFormat ff_pix_fmt)
|
||||
{
|
||||
int num_formats = sizeof(ffmpeg_dirac_pixel_format_map) /
|
||||
sizeof(ffmpeg_dirac_pixel_format_map[0]);
|
||||
int num_formats = sizeof(dirac_pixel_format_map) /
|
||||
sizeof(dirac_pixel_format_map[0]);
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < num_formats; ++idx)
|
||||
if (ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt == ff_pix_fmt)
|
||||
return ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt;
|
||||
if (dirac_pixel_format_map[idx].ff_pix_fmt == ff_pix_fmt)
|
||||
return dirac_pixel_format_map[idx].dirac_pix_fmt;
|
||||
return formatNK;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ static VideoFormat GetDiracVideoFormatPreset(AVCodecContext *avccontext)
|
||||
static av_cold int libdirac_encode_init(AVCodecContext *avccontext)
|
||||
{
|
||||
|
||||
FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data;
|
||||
DiracEncoderParams* p_dirac_params = avccontext->priv_data;
|
||||
int no_local = 1;
|
||||
int verbose = avccontext->debug;
|
||||
VideoFormat preset;
|
||||
@ -219,7 +219,7 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext)
|
||||
|
||||
static void DiracFreeFrame(void *data)
|
||||
{
|
||||
FfmpegDiracSchroEncodedFrame *enc_frame = data;
|
||||
DiracSchroEncodedFrame *enc_frame = data;
|
||||
|
||||
av_freep(&(enc_frame->p_encbuf));
|
||||
av_free(enc_frame);
|
||||
@ -231,9 +231,9 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
|
||||
{
|
||||
int enc_size = 0;
|
||||
dirac_encoder_state_t state;
|
||||
FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data;
|
||||
FfmpegDiracSchroEncodedFrame* p_frame_output = NULL;
|
||||
FfmpegDiracSchroEncodedFrame* p_next_output_frame = NULL;
|
||||
DiracEncoderParams *p_dirac_params = avccontext->priv_data;
|
||||
DiracSchroEncodedFrame *p_frame_output = NULL;
|
||||
DiracSchroEncodedFrame *p_next_output_frame = NULL;
|
||||
int go = 1;
|
||||
int last_frame_in_sequence = 0;
|
||||
|
||||
@ -303,7 +303,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
|
||||
break;
|
||||
|
||||
/* create output frame */
|
||||
p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame));
|
||||
p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame));
|
||||
/* set output data */
|
||||
p_frame_output->size = p_dirac_params->enc_buf_size;
|
||||
p_frame_output->p_encbuf = p_dirac_params->enc_buf;
|
||||
@ -371,7 +371,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext,
|
||||
|
||||
static av_cold int libdirac_encode_close(AVCodecContext *avccontext)
|
||||
{
|
||||
FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data;
|
||||
DiracEncoderParams *p_dirac_params = avccontext->priv_data;
|
||||
|
||||
/* close the encoder */
|
||||
dirac_encoder_close(p_dirac_params->p_encoder);
|
||||
@ -395,7 +395,7 @@ AVCodec ff_libdirac_encoder = {
|
||||
.name = "libdirac",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_DIRAC,
|
||||
.priv_data_size = sizeof(FfmpegDiracEncoderParams),
|
||||
.priv_data_size = sizeof(DiracEncoderParams),
|
||||
.init = libdirac_encode_init,
|
||||
.encode = libdirac_encode_frame,
|
||||
.close = libdirac_encode_close,
|
||||
|
@ -64,14 +64,14 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext
|
||||
int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
|
||||
SchroFrameFormat *schro_frame_fmt)
|
||||
{
|
||||
unsigned int num_formats = sizeof(ffmpeg_schro_pixel_format_map) /
|
||||
sizeof(ffmpeg_schro_pixel_format_map[0]);
|
||||
unsigned int num_formats = sizeof(schro_pixel_format_map) /
|
||||
sizeof(schro_pixel_format_map[0]);
|
||||
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < num_formats; ++idx) {
|
||||
if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
|
||||
*schro_frame_fmt = ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt;
|
||||
if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
|
||||
*schro_frame_fmt = schro_pixel_format_map[idx].schro_frame_fmt;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ static const struct {
|
||||
enum PixelFormat ff_pix_fmt;
|
||||
SchroChromaFormat schro_pix_fmt;
|
||||
SchroFrameFormat schro_frame_fmt;
|
||||
} ffmpeg_schro_pixel_format_map[] = {
|
||||
} schro_pixel_format_map[] = {
|
||||
{ PIX_FMT_YUV420P, SCHRO_CHROMA_420, SCHRO_FRAME_FORMAT_U8_420 },
|
||||
{ PIX_FMT_YUV422P, SCHRO_CHROMA_422, SCHRO_FRAME_FORMAT_U8_422 },
|
||||
{ PIX_FMT_YUV444P, SCHRO_CHROMA_444, SCHRO_FRAME_FORMAT_U8_444 },
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <schroedinger/schrovideoformat.h>
|
||||
|
||||
/** libschroedinger decoder private data */
|
||||
typedef struct FfmpegSchroDecoderParams {
|
||||
typedef struct SchroDecoderParams {
|
||||
/** Schroedinger video format */
|
||||
SchroVideoFormat *format;
|
||||
|
||||
@ -52,7 +52,7 @@ typedef struct FfmpegSchroDecoderParams {
|
||||
SchroDecoder* decoder;
|
||||
|
||||
/** queue storing decoded frames */
|
||||
FfmpegDiracSchroQueue dec_frame_queue;
|
||||
DiracSchroQueue dec_frame_queue;
|
||||
|
||||
/** end of sequence signalled */
|
||||
int eos_signalled;
|
||||
@ -62,25 +62,25 @@ typedef struct FfmpegSchroDecoderParams {
|
||||
|
||||
/** decoded picture */
|
||||
AVPicture dec_pic;
|
||||
} FfmpegSchroDecoderParams;
|
||||
} SchroDecoderParams;
|
||||
|
||||
typedef struct FfmpegSchroParseUnitContext {
|
||||
typedef struct SchroParseUnitContext {
|
||||
const uint8_t *buf;
|
||||
int buf_size;
|
||||
} FfmpegSchroParseUnitContext;
|
||||
} SchroParseUnitContext;
|
||||
|
||||
|
||||
static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf,
|
||||
void *priv);
|
||||
|
||||
static void FfmpegSchroParseContextInit(FfmpegSchroParseUnitContext *parse_ctx,
|
||||
const uint8_t *buf, int buf_size)
|
||||
static void SchroParseContextInit(SchroParseUnitContext *parse_ctx,
|
||||
const uint8_t *buf, int buf_size)
|
||||
{
|
||||
parse_ctx->buf = buf;
|
||||
parse_ctx->buf_size = buf_size;
|
||||
}
|
||||
|
||||
static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *parse_ctx)
|
||||
static SchroBuffer *FindNextSchroParseUnit(SchroParseUnitContext *parse_ctx)
|
||||
{
|
||||
SchroBuffer *enc_buf = NULL;
|
||||
int next_pu_offset = 0;
|
||||
@ -120,22 +120,22 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *pa
|
||||
/**
|
||||
* Returns FFmpeg chroma format.
|
||||
*/
|
||||
static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt)
|
||||
static enum PixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt)
|
||||
{
|
||||
int num_formats = sizeof(ffmpeg_schro_pixel_format_map) /
|
||||
sizeof(ffmpeg_schro_pixel_format_map[0]);
|
||||
int num_formats = sizeof(schro_pixel_format_map) /
|
||||
sizeof(schro_pixel_format_map[0]);
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < num_formats; ++idx)
|
||||
if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt)
|
||||
return ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt;
|
||||
if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt)
|
||||
return schro_pixel_format_map[idx].ff_pix_fmt;
|
||||
return PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
|
||||
{
|
||||
|
||||
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
/* First of all, initialize our supporting libraries. */
|
||||
schro_init();
|
||||
|
||||
@ -164,7 +164,7 @@ static void libschroedinger_decode_frame_free(void *frame)
|
||||
|
||||
static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
|
||||
{
|
||||
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoder *decoder = p_schro_params->decoder;
|
||||
|
||||
p_schro_params->format = schro_decoder_get_video_format(decoder);
|
||||
@ -179,7 +179,7 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
|
||||
}
|
||||
avccontext->height = p_schro_params->format->height;
|
||||
avccontext->width = p_schro_params->format->width;
|
||||
avccontext->pix_fmt = GetFfmpegChromaFormat(p_schro_params->format->chroma_format);
|
||||
avccontext->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format);
|
||||
|
||||
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
|
||||
&p_schro_params->frame_format) == -1) {
|
||||
@ -206,7 +206,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
|
||||
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoder *decoder = p_schro_params->decoder;
|
||||
AVPicture *picture = data;
|
||||
SchroBuffer *enc_buf;
|
||||
@ -214,11 +214,11 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
|
||||
int state;
|
||||
int go = 1;
|
||||
int outer = 1;
|
||||
FfmpegSchroParseUnitContext parse_ctx;
|
||||
SchroParseUnitContext parse_ctx;
|
||||
|
||||
*data_size = 0;
|
||||
|
||||
FfmpegSchroParseContextInit(&parse_ctx, buf, buf_size);
|
||||
SchroParseContextInit(&parse_ctx, buf, buf_size);
|
||||
if (!buf_size) {
|
||||
if (!p_schro_params->eos_signalled) {
|
||||
state = schro_decoder_push_end_of_stream(decoder);
|
||||
@ -228,7 +228,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
|
||||
|
||||
/* Loop through all the individual parse units in the input buffer */
|
||||
do {
|
||||
if ((enc_buf = FfmpegFindNextSchroParseUnit(&parse_ctx))) {
|
||||
if ((enc_buf = FindNextSchroParseUnit(&parse_ctx))) {
|
||||
/* Push buffer into decoder. */
|
||||
if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
|
||||
SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
|
||||
@ -314,7 +314,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
|
||||
|
||||
static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext)
|
||||
{
|
||||
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
/* Free the decoder. */
|
||||
schro_decoder_free(p_schro_params->decoder);
|
||||
av_freep(&p_schro_params->format);
|
||||
@ -332,7 +332,7 @@ static void libschroedinger_flush(AVCodecContext *avccontext)
|
||||
{
|
||||
/* Got a seek request. Free the decoded frames queue and then reset
|
||||
* the decoder */
|
||||
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroDecoderParams *p_schro_params = avccontext->priv_data;
|
||||
|
||||
/* Free data in the output frame queue. */
|
||||
ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue,
|
||||
@ -348,7 +348,7 @@ AVCodec ff_libschroedinger_decoder = {
|
||||
.name = "libschroedinger",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_DIRAC,
|
||||
.priv_data_size = sizeof(FfmpegSchroDecoderParams),
|
||||
.priv_data_size = sizeof(SchroDecoderParams),
|
||||
.init = libschroedinger_decode_init,
|
||||
.close = libschroedinger_decode_close,
|
||||
.decode = libschroedinger_decode_frame,
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
|
||||
/** libschroedinger encoder private data */
|
||||
typedef struct FfmpegSchroEncoderParams {
|
||||
typedef struct SchroEncoderParams {
|
||||
/** Schroedinger video format */
|
||||
SchroVideoFormat *format;
|
||||
|
||||
@ -64,31 +64,31 @@ typedef struct FfmpegSchroEncoderParams {
|
||||
int enc_buf_size;
|
||||
|
||||
/** queue storing encoded frames */
|
||||
FfmpegDiracSchroQueue enc_frame_queue;
|
||||
DiracSchroQueue enc_frame_queue;
|
||||
|
||||
/** end of sequence signalled */
|
||||
int eos_signalled;
|
||||
|
||||
/** end of sequence pulled */
|
||||
int eos_pulled;
|
||||
} FfmpegSchroEncoderParams;
|
||||
} SchroEncoderParams;
|
||||
|
||||
/**
|
||||
* Works out Schro-compatible chroma format.
|
||||
*/
|
||||
static int SetSchroChromaFormat(AVCodecContext *avccontext)
|
||||
{
|
||||
int num_formats = sizeof(ffmpeg_schro_pixel_format_map) /
|
||||
sizeof(ffmpeg_schro_pixel_format_map[0]);
|
||||
int num_formats = sizeof(schro_pixel_format_map) /
|
||||
sizeof(schro_pixel_format_map[0]);
|
||||
int idx;
|
||||
|
||||
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data;
|
||||
SchroEncoderParams *p_schro_params = avccontext->priv_data;
|
||||
|
||||
for (idx = 0; idx < num_formats; ++idx) {
|
||||
if (ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt ==
|
||||
if (schro_pixel_format_map[idx].ff_pix_fmt ==
|
||||
avccontext->pix_fmt) {
|
||||
p_schro_params->format->chroma_format =
|
||||
ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt;
|
||||
schro_pixel_format_map[idx].schro_pix_fmt;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ static int SetSchroChromaFormat(AVCodecContext *avccontext)
|
||||
|
||||
static int libschroedinger_encode_init(AVCodecContext *avccontext)
|
||||
{
|
||||
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data;
|
||||
SchroEncoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroVideoFormatEnum preset;
|
||||
|
||||
/* Initialize the libraries that libschroedinger depends on. */
|
||||
@ -238,7 +238,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext)
|
||||
static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext,
|
||||
void *in_data)
|
||||
{
|
||||
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data;
|
||||
SchroEncoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroFrame *in_frame;
|
||||
/* Input line size may differ from what the codec supports. Especially
|
||||
* when transcoding from one format to another. So use avpicture_layout
|
||||
@ -256,7 +256,7 @@ static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext,
|
||||
|
||||
static void SchroedingerFreeFrame(void *data)
|
||||
{
|
||||
FfmpegDiracSchroEncodedFrame *enc_frame = data;
|
||||
DiracSchroEncodedFrame *enc_frame = data;
|
||||
|
||||
av_freep(&(enc_frame->p_encbuf));
|
||||
av_free(enc_frame);
|
||||
@ -267,9 +267,9 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
|
||||
int buf_size, void *data)
|
||||
{
|
||||
int enc_size = 0;
|
||||
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data;
|
||||
SchroEncoderParams *p_schro_params = avccontext->priv_data;
|
||||
SchroEncoder *encoder = p_schro_params->encoder;
|
||||
struct FfmpegDiracSchroEncodedFrame* p_frame_output = NULL;
|
||||
struct DiracSchroEncodedFrame *p_frame_output = NULL;
|
||||
int go = 1;
|
||||
SchroBuffer *enc_buf;
|
||||
int presentation_frame;
|
||||
@ -328,7 +328,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
|
||||
}
|
||||
|
||||
/* Create output frame. */
|
||||
p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame));
|
||||
p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame));
|
||||
/* Set output data. */
|
||||
p_frame_output->size = p_schro_params->enc_buf_size;
|
||||
p_frame_output->p_encbuf = p_schro_params->enc_buf;
|
||||
@ -400,8 +400,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext,
|
||||
|
||||
static int libschroedinger_encode_close(AVCodecContext *avccontext)
|
||||
{
|
||||
|
||||
FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data;
|
||||
SchroEncoderParams *p_schro_params = avccontext->priv_data;
|
||||
|
||||
/* Close the encoder. */
|
||||
schro_encoder_free(p_schro_params->encoder);
|
||||
@ -426,7 +425,7 @@ AVCodec ff_libschroedinger_encoder = {
|
||||
.name = "libschroedinger",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_DIRAC,
|
||||
.priv_data_size = sizeof(FfmpegSchroEncoderParams),
|
||||
.priv_data_size = sizeof(SchroEncoderParams),
|
||||
.init = libschroedinger_encode_init,
|
||||
.encode = libschroedinger_encode_frame,
|
||||
.close = libschroedinger_encode_close,
|
||||
|
Loading…
Reference in New Issue
Block a user