* qatar/master:
libdirac/libschroedinger: Drop unnecessary symbol prefixes.
cmdutils: check fread() return value
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -809,6 +809,7 @@ int read_yesno(void) |
| 809 | 809 |
|
| 810 | 810 |
int read_file(const char *filename, char **bufptr, size_t *size) |
| 811 | 811 |
{
|
| 812 |
+ int ret; |
|
| 812 | 813 |
FILE *f = fopen(filename, "rb"); |
| 813 | 814 |
|
| 814 | 815 |
if (!f) {
|
| ... | ... |
@@ -824,11 +825,22 @@ int read_file(const char *filename, char **bufptr, size_t *size) |
| 824 | 824 |
fclose(f); |
| 825 | 825 |
return AVERROR(ENOMEM); |
| 826 | 826 |
} |
| 827 |
- fread(*bufptr, 1, *size, f); |
|
| 828 |
- (*bufptr)[*size++] = '\0'; |
|
| 827 |
+ ret = fread(*bufptr, 1, *size, f); |
|
| 828 |
+ if (ret < *size) {
|
|
| 829 |
+ av_free(*bufptr); |
|
| 830 |
+ if (ferror(f)) {
|
|
| 831 |
+ av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n", |
|
| 832 |
+ filename, strerror(errno)); |
|
| 833 |
+ ret = AVERROR(errno); |
|
| 834 |
+ } else |
|
| 835 |
+ ret = AVERROR_EOF; |
|
| 836 |
+ } else {
|
|
| 837 |
+ ret = 0; |
|
| 838 |
+ (*bufptr)[*size++] = '\0'; |
|
| 839 |
+ } |
|
| 829 | 840 |
|
| 830 | 841 |
fclose(f); |
| 831 |
- return 0; |
|
| 842 |
+ return ret; |
|
| 832 | 843 |
} |
| 833 | 844 |
|
| 834 | 845 |
FILE *get_preset_file(char *filename, size_t filename_size, |
| ... | ... |
@@ -35,7 +35,7 @@ |
| 35 | 35 |
static const struct {
|
| 36 | 36 |
enum PixelFormat ff_pix_fmt; |
| 37 | 37 |
dirac_chroma_t dirac_pix_fmt; |
| 38 |
-} ffmpeg_dirac_pixel_format_map[] = {
|
|
| 38 |
+} dirac_pixel_format_map[] = {
|
|
| 39 | 39 |
{ PIX_FMT_YUV420P, format420 },
|
| 40 | 40 |
{ PIX_FMT_YUV422P, format422 },
|
| 41 | 41 |
{ PIX_FMT_YUV444P, format444 },
|
| ... | ... |
@@ -25,7 +25,7 @@ |
| 25 | 25 |
|
| 26 | 26 |
#include "libdirac_libschro.h" |
| 27 | 27 |
|
| 28 |
-static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
|
|
| 28 |
+static const DiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
|
|
| 29 | 29 |
{ 640, 480, 24000, 1001},
|
| 30 | 30 |
{ 176, 120, 15000, 1001},
|
| 31 | 31 |
{ 176, 144, 25, 2 },
|
| ... | ... |
@@ -53,7 +53,7 @@ unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext) |
| 53 | 53 |
sizeof(ff_dirac_schro_video_format_info[0]); |
| 54 | 54 |
|
| 55 | 55 |
for (idx = 1; idx < num_formats; ++idx) {
|
| 56 |
- const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx]; |
|
| 56 |
+ const DiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx]; |
|
| 57 | 57 |
if (avccontext->width == vf->width && |
| 58 | 58 |
avccontext->height == vf->height) {
|
| 59 | 59 |
ret_idx = idx; |
| ... | ... |
@@ -65,22 +65,22 @@ unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext) |
| 65 | 65 |
return ret_idx; |
| 66 | 66 |
} |
| 67 | 67 |
|
| 68 |
-void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue) |
|
| 68 |
+void ff_dirac_schro_queue_init(DiracSchroQueue *queue) |
|
| 69 | 69 |
{
|
| 70 | 70 |
queue->p_head = queue->p_tail = NULL; |
| 71 | 71 |
queue->size = 0; |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
-void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue, |
|
| 74 |
+void ff_dirac_schro_queue_free(DiracSchroQueue *queue, |
|
| 75 | 75 |
void (*free_func)(void *)) |
| 76 | 76 |
{
|
| 77 | 77 |
while (queue->p_head) |
| 78 | 78 |
free_func(ff_dirac_schro_queue_pop(queue)); |
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 |
-int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data) |
|
| 81 |
+int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data) |
|
| 82 | 82 |
{
|
| 83 |
- FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement)); |
|
| 83 |
+ DiracSchroQueueElement *p_new = av_mallocz(sizeof(DiracSchroQueueElement)); |
|
| 84 | 84 |
|
| 85 | 85 |
if (!p_new) |
| 86 | 86 |
return -1; |
| ... | ... |
@@ -97,9 +97,9 @@ int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data) |
| 97 | 97 |
return 0; |
| 98 | 98 |
} |
| 99 | 99 |
|
| 100 |
-void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue) |
|
| 100 |
+void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue) |
|
| 101 | 101 |
{
|
| 102 |
- FfmpegDiracSchroQueueElement *top = queue->p_head; |
|
| 102 |
+ DiracSchroQueueElement *top = queue->p_head; |
|
| 103 | 103 |
|
| 104 | 104 |
if (top) {
|
| 105 | 105 |
void *data = top->data; |
| ... | ... |
@@ -33,7 +33,7 @@ typedef struct {
|
| 33 | 33 |
uint16_t height; |
| 34 | 34 |
uint16_t frame_rate_num; |
| 35 | 35 |
uint16_t frame_rate_denom; |
| 36 |
-} FfmpegDiracSchroVideoFormatInfo; |
|
| 36 |
+} DiracSchroVideoFormatInfo; |
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* 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); |
| 43 | 43 |
/** |
| 44 | 44 |
* contains a single encoded frame returned from Dirac or Schroedinger |
| 45 | 45 |
*/ |
| 46 |
-typedef struct FfmpegDiracSchroEncodedFrame {
|
|
| 46 |
+typedef struct DiracSchroEncodedFrame {
|
|
| 47 | 47 |
/** encoded frame data */ |
| 48 | 48 |
uint8_t *p_encbuf; |
| 49 | 49 |
|
| ... | ... |
@@ -55,51 +55,51 @@ typedef struct FfmpegDiracSchroEncodedFrame {
|
| 55 | 55 |
|
| 56 | 56 |
/** key frame flag. 1 : is key frame , 0 : in not key frame */ |
| 57 | 57 |
uint16_t key_frame; |
| 58 |
-} FfmpegDiracSchroEncodedFrame; |
|
| 58 |
+} DiracSchroEncodedFrame; |
|
| 59 | 59 |
|
| 60 | 60 |
/** |
| 61 | 61 |
* queue element |
| 62 | 62 |
*/ |
| 63 |
-typedef struct FfmpegDiracSchroQueueElement {
|
|
| 63 |
+typedef struct DiracSchroQueueElement {
|
|
| 64 | 64 |
/** Data to be stored in queue*/ |
| 65 | 65 |
void *data; |
| 66 | 66 |
/** Pointer to next element queue */ |
| 67 |
- struct FfmpegDiracSchroQueueElement *next; |
|
| 68 |
-} FfmpegDiracSchroQueueElement; |
|
| 67 |
+ struct DiracSchroQueueElement *next; |
|
| 68 |
+} DiracSchroQueueElement; |
|
| 69 | 69 |
|
| 70 | 70 |
|
| 71 | 71 |
/** |
| 72 | 72 |
* A simple queue implementation used in libdirac and libschroedinger |
| 73 | 73 |
*/ |
| 74 |
-typedef struct FfmpegDiracSchroQueue {
|
|
| 74 |
+typedef struct DiracSchroQueue {
|
|
| 75 | 75 |
/** Pointer to head of queue */ |
| 76 |
- FfmpegDiracSchroQueueElement *p_head; |
|
| 76 |
+ DiracSchroQueueElement *p_head; |
|
| 77 | 77 |
/** Pointer to tail of queue */ |
| 78 |
- FfmpegDiracSchroQueueElement *p_tail; |
|
| 78 |
+ DiracSchroQueueElement *p_tail; |
|
| 79 | 79 |
/** Queue size*/ |
| 80 | 80 |
int size; |
| 81 |
-} FfmpegDiracSchroQueue; |
|
| 81 |
+} DiracSchroQueue; |
|
| 82 | 82 |
|
| 83 | 83 |
/** |
| 84 | 84 |
* Initialise the queue |
| 85 | 85 |
*/ |
| 86 |
-void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue); |
|
| 86 |
+void ff_dirac_schro_queue_init(DiracSchroQueue *queue); |
|
| 87 | 87 |
|
| 88 | 88 |
/** |
| 89 | 89 |
* Add an element to the end of the queue |
| 90 | 90 |
*/ |
| 91 |
-int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data); |
|
| 91 |
+int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data); |
|
| 92 | 92 |
|
| 93 | 93 |
/** |
| 94 | 94 |
* Return the first element in the queue |
| 95 | 95 |
*/ |
| 96 |
-void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue); |
|
| 96 |
+void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue); |
|
| 97 | 97 |
|
| 98 | 98 |
/** |
| 99 | 99 |
* Free the queue resources. free_func is a function supplied by the caller to |
| 100 | 100 |
* free any resources allocated by the caller. The data field of the queue |
| 101 | 101 |
* element is passed to it. |
| 102 | 102 |
*/ |
| 103 |
-void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue, |
|
| 103 |
+void ff_dirac_schro_queue_free(DiracSchroQueue *queue, |
|
| 104 | 104 |
void (*free_func)(void *)); |
| 105 | 105 |
#endif /* AVCODEC_LIBDIRAC_LIBSCHRO_H */ |
| ... | ... |
@@ -37,34 +37,34 @@ |
| 37 | 37 |
#include <libdirac_decoder/dirac_parser.h> |
| 38 | 38 |
|
| 39 | 39 |
/** contains a single frame returned from Dirac */ |
| 40 |
-typedef struct FfmpegDiracDecoderParams {
|
|
| 40 |
+typedef struct DiracDecoderParams {
|
|
| 41 | 41 |
/** decoder handle */ |
| 42 | 42 |
dirac_decoder_t* p_decoder; |
| 43 | 43 |
|
| 44 | 44 |
/** buffer to hold decoded frame */ |
| 45 | 45 |
unsigned char* p_out_frame_buf; |
| 46 |
-} FfmpegDiracDecoderParams; |
|
| 46 |
+} DiracDecoderParams; |
|
| 47 | 47 |
|
| 48 | 48 |
|
| 49 | 49 |
/** |
| 50 | 50 |
* returns FFmpeg chroma format |
| 51 | 51 |
*/ |
| 52 |
-static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) |
|
| 52 |
+static enum PixelFormat get_chroma_format(dirac_chroma_t dirac_pix_fmt) |
|
| 53 | 53 |
{
|
| 54 |
- int num_formats = sizeof(ffmpeg_dirac_pixel_format_map) / |
|
| 55 |
- sizeof(ffmpeg_dirac_pixel_format_map[0]); |
|
| 54 |
+ int num_formats = sizeof(dirac_pixel_format_map) / |
|
| 55 |
+ sizeof(dirac_pixel_format_map[0]); |
|
| 56 | 56 |
int idx; |
| 57 | 57 |
|
| 58 | 58 |
for (idx = 0; idx < num_formats; ++idx) |
| 59 |
- if (ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt) |
|
| 60 |
- return ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt; |
|
| 59 |
+ if (dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt) |
|
| 60 |
+ return dirac_pixel_format_map[idx].ff_pix_fmt; |
|
| 61 | 61 |
return PIX_FMT_NONE; |
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
static av_cold int libdirac_decode_init(AVCodecContext *avccontext) |
| 65 | 65 |
{
|
| 66 | 66 |
|
| 67 |
- FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 67 |
+ DiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 68 | 68 |
p_dirac_params->p_decoder = dirac_decoder_init(avccontext->debug); |
| 69 | 69 |
|
| 70 | 70 |
if (!p_dirac_params->p_decoder) |
| ... | ... |
@@ -80,7 +80,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 80 | 80 |
const uint8_t *buf = avpkt->data; |
| 81 | 81 |
int buf_size = avpkt->size; |
| 82 | 82 |
|
| 83 |
- FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 83 |
+ DiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 84 | 84 |
AVPicture *picture = data; |
| 85 | 85 |
AVPicture pic; |
| 86 | 86 |
int pict_size; |
| ... | ... |
@@ -117,7 +117,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 117 | 117 |
avccontext->height = src_params->height; |
| 118 | 118 |
avccontext->width = src_params->width; |
| 119 | 119 |
|
| 120 |
- avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma); |
|
| 120 |
+ avccontext->pix_fmt = get_chroma_format(src_params->chroma); |
|
| 121 | 121 |
if (avccontext->pix_fmt == PIX_FMT_NONE) {
|
| 122 | 122 |
av_log(avccontext, AV_LOG_ERROR, |
| 123 | 123 |
"Dirac chroma format %d not supported currently\n", |
| ... | ... |
@@ -174,7 +174,7 @@ static int libdirac_decode_frame(AVCodecContext *avccontext, |
| 174 | 174 |
|
| 175 | 175 |
static av_cold int libdirac_decode_close(AVCodecContext *avccontext) |
| 176 | 176 |
{
|
| 177 |
- FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 177 |
+ DiracDecoderParams *p_dirac_params = avccontext->priv_data; |
|
| 178 | 178 |
dirac_decoder_close(p_dirac_params->p_decoder); |
| 179 | 179 |
|
| 180 | 180 |
av_freep(&p_dirac_params->p_out_frame_buf); |
| ... | ... |
@@ -198,7 +198,7 @@ AVCodec ff_libdirac_decoder = {
|
| 198 | 198 |
.name = "libdirac", |
| 199 | 199 |
.type = AVMEDIA_TYPE_VIDEO, |
| 200 | 200 |
.id = CODEC_ID_DIRAC, |
| 201 |
- .priv_data_size = sizeof(FfmpegDiracDecoderParams), |
|
| 201 |
+ .priv_data_size = sizeof(DiracDecoderParams), |
|
| 202 | 202 |
.init = libdirac_decode_init, |
| 203 | 203 |
.close = libdirac_decode_close, |
| 204 | 204 |
.decode = libdirac_decode_frame, |
| ... | ... |
@@ -38,7 +38,7 @@ |
| 38 | 38 |
#include <libdirac_encoder/dirac_encoder.h> |
| 39 | 39 |
|
| 40 | 40 |
/** Dirac encoder private data */ |
| 41 |
-typedef struct FfmpegDiracEncoderParams {
|
|
| 41 |
+typedef struct DiracEncoderParams {
|
|
| 42 | 42 |
/** Dirac encoder context */ |
| 43 | 43 |
dirac_encoder_context_t enc_ctx; |
| 44 | 44 |
|
| ... | ... |
@@ -61,27 +61,27 @@ typedef struct FfmpegDiracEncoderParams {
|
| 61 | 61 |
int enc_buf_size; |
| 62 | 62 |
|
| 63 | 63 |
/** queue storing encoded frames */ |
| 64 |
- FfmpegDiracSchroQueue enc_frame_queue; |
|
| 64 |
+ DiracSchroQueue enc_frame_queue; |
|
| 65 | 65 |
|
| 66 | 66 |
/** end of sequence signalled by user, 0 - false, 1 - true */ |
| 67 | 67 |
int eos_signalled; |
| 68 | 68 |
|
| 69 | 69 |
/** end of sequence returned by encoder, 0 - false, 1 - true */ |
| 70 | 70 |
int eos_pulled; |
| 71 |
-} FfmpegDiracEncoderParams; |
|
| 71 |
+} DiracEncoderParams; |
|
| 72 | 72 |
|
| 73 | 73 |
/** |
| 74 | 74 |
* Works out Dirac-compatible chroma format. |
| 75 | 75 |
*/ |
| 76 | 76 |
static dirac_chroma_t GetDiracChromaFormat(enum PixelFormat ff_pix_fmt) |
| 77 | 77 |
{
|
| 78 |
- int num_formats = sizeof(ffmpeg_dirac_pixel_format_map) / |
|
| 79 |
- sizeof(ffmpeg_dirac_pixel_format_map[0]); |
|
| 78 |
+ int num_formats = sizeof(dirac_pixel_format_map) / |
|
| 79 |
+ sizeof(dirac_pixel_format_map[0]); |
|
| 80 | 80 |
int idx; |
| 81 | 81 |
|
| 82 | 82 |
for (idx = 0; idx < num_formats; ++idx) |
| 83 |
- if (ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt == ff_pix_fmt) |
|
| 84 |
- return ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt; |
|
| 83 |
+ if (dirac_pixel_format_map[idx].ff_pix_fmt == ff_pix_fmt) |
|
| 84 |
+ return dirac_pixel_format_map[idx].dirac_pix_fmt; |
|
| 85 | 85 |
return formatNK; |
| 86 | 86 |
} |
| 87 | 87 |
|
| ... | ... |
@@ -127,7 +127,7 @@ static VideoFormat GetDiracVideoFormatPreset(AVCodecContext *avccontext) |
| 127 | 127 |
static av_cold int libdirac_encode_init(AVCodecContext *avccontext) |
| 128 | 128 |
{
|
| 129 | 129 |
|
| 130 |
- FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; |
|
| 130 |
+ DiracEncoderParams* p_dirac_params = avccontext->priv_data; |
|
| 131 | 131 |
int no_local = 1; |
| 132 | 132 |
int verbose = avccontext->debug; |
| 133 | 133 |
VideoFormat preset; |
| ... | ... |
@@ -219,7 +219,7 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext) |
| 219 | 219 |
|
| 220 | 220 |
static void DiracFreeFrame(void *data) |
| 221 | 221 |
{
|
| 222 |
- FfmpegDiracSchroEncodedFrame *enc_frame = data; |
|
| 222 |
+ DiracSchroEncodedFrame *enc_frame = data; |
|
| 223 | 223 |
|
| 224 | 224 |
av_freep(&(enc_frame->p_encbuf)); |
| 225 | 225 |
av_free(enc_frame); |
| ... | ... |
@@ -231,9 +231,9 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 231 | 231 |
{
|
| 232 | 232 |
int enc_size = 0; |
| 233 | 233 |
dirac_encoder_state_t state; |
| 234 |
- FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; |
|
| 235 |
- FfmpegDiracSchroEncodedFrame* p_frame_output = NULL; |
|
| 236 |
- FfmpegDiracSchroEncodedFrame* p_next_output_frame = NULL; |
|
| 234 |
+ DiracEncoderParams *p_dirac_params = avccontext->priv_data; |
|
| 235 |
+ DiracSchroEncodedFrame *p_frame_output = NULL; |
|
| 236 |
+ DiracSchroEncodedFrame *p_next_output_frame = NULL; |
|
| 237 | 237 |
int go = 1; |
| 238 | 238 |
int last_frame_in_sequence = 0; |
| 239 | 239 |
|
| ... | ... |
@@ -303,7 +303,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 303 | 303 |
break; |
| 304 | 304 |
|
| 305 | 305 |
/* create output frame */ |
| 306 |
- p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame)); |
|
| 306 |
+ p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame)); |
|
| 307 | 307 |
/* set output data */ |
| 308 | 308 |
p_frame_output->size = p_dirac_params->enc_buf_size; |
| 309 | 309 |
p_frame_output->p_encbuf = p_dirac_params->enc_buf; |
| ... | ... |
@@ -371,7 +371,7 @@ static int libdirac_encode_frame(AVCodecContext *avccontext, |
| 371 | 371 |
|
| 372 | 372 |
static av_cold int libdirac_encode_close(AVCodecContext *avccontext) |
| 373 | 373 |
{
|
| 374 |
- FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; |
|
| 374 |
+ DiracEncoderParams *p_dirac_params = avccontext->priv_data; |
|
| 375 | 375 |
|
| 376 | 376 |
/* close the encoder */ |
| 377 | 377 |
dirac_encoder_close(p_dirac_params->p_encoder); |
| ... | ... |
@@ -395,7 +395,7 @@ AVCodec ff_libdirac_encoder = {
|
| 395 | 395 |
.name = "libdirac", |
| 396 | 396 |
.type = AVMEDIA_TYPE_VIDEO, |
| 397 | 397 |
.id = CODEC_ID_DIRAC, |
| 398 |
- .priv_data_size = sizeof(FfmpegDiracEncoderParams), |
|
| 398 |
+ .priv_data_size = sizeof(DiracEncoderParams), |
|
| 399 | 399 |
.init = libdirac_encode_init, |
| 400 | 400 |
.encode = libdirac_encode_frame, |
| 401 | 401 |
.close = libdirac_encode_close, |
| ... | ... |
@@ -64,14 +64,14 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext |
| 64 | 64 |
int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt, |
| 65 | 65 |
SchroFrameFormat *schro_frame_fmt) |
| 66 | 66 |
{
|
| 67 |
- unsigned int num_formats = sizeof(ffmpeg_schro_pixel_format_map) / |
|
| 68 |
- sizeof(ffmpeg_schro_pixel_format_map[0]); |
|
| 67 |
+ unsigned int num_formats = sizeof(schro_pixel_format_map) / |
|
| 68 |
+ sizeof(schro_pixel_format_map[0]); |
|
| 69 | 69 |
|
| 70 | 70 |
int idx; |
| 71 | 71 |
|
| 72 | 72 |
for (idx = 0; idx < num_formats; ++idx) {
|
| 73 |
- if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
|
|
| 74 |
- *schro_frame_fmt = ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt; |
|
| 73 |
+ if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
|
|
| 74 |
+ *schro_frame_fmt = schro_pixel_format_map[idx].schro_frame_fmt; |
|
| 75 | 75 |
return 0; |
| 76 | 76 |
} |
| 77 | 77 |
} |
| ... | ... |
@@ -34,7 +34,7 @@ static const struct {
|
| 34 | 34 |
enum PixelFormat ff_pix_fmt; |
| 35 | 35 |
SchroChromaFormat schro_pix_fmt; |
| 36 | 36 |
SchroFrameFormat schro_frame_fmt; |
| 37 |
-} ffmpeg_schro_pixel_format_map[] = {
|
|
| 37 |
+} schro_pixel_format_map[] = {
|
|
| 38 | 38 |
{ PIX_FMT_YUV420P, SCHRO_CHROMA_420, SCHRO_FRAME_FORMAT_U8_420 },
|
| 39 | 39 |
{ PIX_FMT_YUV422P, SCHRO_CHROMA_422, SCHRO_FRAME_FORMAT_U8_422 },
|
| 40 | 40 |
{ PIX_FMT_YUV444P, SCHRO_CHROMA_444, SCHRO_FRAME_FORMAT_U8_444 },
|
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
#include <schroedinger/schrovideoformat.h> |
| 42 | 42 |
|
| 43 | 43 |
/** libschroedinger decoder private data */ |
| 44 |
-typedef struct FfmpegSchroDecoderParams {
|
|
| 44 |
+typedef struct SchroDecoderParams {
|
|
| 45 | 45 |
/** Schroedinger video format */ |
| 46 | 46 |
SchroVideoFormat *format; |
| 47 | 47 |
|
| ... | ... |
@@ -52,7 +52,7 @@ typedef struct FfmpegSchroDecoderParams {
|
| 52 | 52 |
SchroDecoder* decoder; |
| 53 | 53 |
|
| 54 | 54 |
/** queue storing decoded frames */ |
| 55 |
- FfmpegDiracSchroQueue dec_frame_queue; |
|
| 55 |
+ DiracSchroQueue dec_frame_queue; |
|
| 56 | 56 |
|
| 57 | 57 |
/** end of sequence signalled */ |
| 58 | 58 |
int eos_signalled; |
| ... | ... |
@@ -62,25 +62,25 @@ typedef struct FfmpegSchroDecoderParams {
|
| 62 | 62 |
|
| 63 | 63 |
/** decoded picture */ |
| 64 | 64 |
AVPicture dec_pic; |
| 65 |
-} FfmpegSchroDecoderParams; |
|
| 65 |
+} SchroDecoderParams; |
|
| 66 | 66 |
|
| 67 |
-typedef struct FfmpegSchroParseUnitContext {
|
|
| 67 |
+typedef struct SchroParseUnitContext {
|
|
| 68 | 68 |
const uint8_t *buf; |
| 69 | 69 |
int buf_size; |
| 70 |
-} FfmpegSchroParseUnitContext; |
|
| 70 |
+} SchroParseUnitContext; |
|
| 71 | 71 |
|
| 72 | 72 |
|
| 73 | 73 |
static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, |
| 74 | 74 |
void *priv); |
| 75 | 75 |
|
| 76 |
-static void FfmpegSchroParseContextInit(FfmpegSchroParseUnitContext *parse_ctx, |
|
| 77 |
- const uint8_t *buf, int buf_size) |
|
| 76 |
+static void SchroParseContextInit(SchroParseUnitContext *parse_ctx, |
|
| 77 |
+ const uint8_t *buf, int buf_size) |
|
| 78 | 78 |
{
|
| 79 | 79 |
parse_ctx->buf = buf; |
| 80 | 80 |
parse_ctx->buf_size = buf_size; |
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 |
-static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *parse_ctx) |
|
| 83 |
+static SchroBuffer *FindNextSchroParseUnit(SchroParseUnitContext *parse_ctx) |
|
| 84 | 84 |
{
|
| 85 | 85 |
SchroBuffer *enc_buf = NULL; |
| 86 | 86 |
int next_pu_offset = 0; |
| ... | ... |
@@ -120,22 +120,22 @@ static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *pa |
| 120 | 120 |
/** |
| 121 | 121 |
* Returns FFmpeg chroma format. |
| 122 | 122 |
*/ |
| 123 |
-static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt) |
|
| 123 |
+static enum PixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt) |
|
| 124 | 124 |
{
|
| 125 |
- int num_formats = sizeof(ffmpeg_schro_pixel_format_map) / |
|
| 126 |
- sizeof(ffmpeg_schro_pixel_format_map[0]); |
|
| 125 |
+ int num_formats = sizeof(schro_pixel_format_map) / |
|
| 126 |
+ sizeof(schro_pixel_format_map[0]); |
|
| 127 | 127 |
int idx; |
| 128 | 128 |
|
| 129 | 129 |
for (idx = 0; idx < num_formats; ++idx) |
| 130 |
- if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) |
|
| 131 |
- return ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt; |
|
| 130 |
+ if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) |
|
| 131 |
+ return schro_pixel_format_map[idx].ff_pix_fmt; |
|
| 132 | 132 |
return PIX_FMT_NONE; |
| 133 | 133 |
} |
| 134 | 134 |
|
| 135 | 135 |
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext) |
| 136 | 136 |
{
|
| 137 | 137 |
|
| 138 |
- FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 138 |
+ SchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 139 | 139 |
/* First of all, initialize our supporting libraries. */ |
| 140 | 140 |
schro_init(); |
| 141 | 141 |
|
| ... | ... |
@@ -164,7 +164,7 @@ static void libschroedinger_decode_frame_free(void *frame) |
| 164 | 164 |
|
| 165 | 165 |
static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) |
| 166 | 166 |
{
|
| 167 |
- FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 167 |
+ SchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 168 | 168 |
SchroDecoder *decoder = p_schro_params->decoder; |
| 169 | 169 |
|
| 170 | 170 |
p_schro_params->format = schro_decoder_get_video_format(decoder); |
| ... | ... |
@@ -179,7 +179,7 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) |
| 179 | 179 |
} |
| 180 | 180 |
avccontext->height = p_schro_params->format->height; |
| 181 | 181 |
avccontext->width = p_schro_params->format->width; |
| 182 |
- avccontext->pix_fmt = GetFfmpegChromaFormat(p_schro_params->format->chroma_format); |
|
| 182 |
+ avccontext->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format); |
|
| 183 | 183 |
|
| 184 | 184 |
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format, |
| 185 | 185 |
&p_schro_params->frame_format) == -1) {
|
| ... | ... |
@@ -206,7 +206,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 206 | 206 |
const uint8_t *buf = avpkt->data; |
| 207 | 207 |
int buf_size = avpkt->size; |
| 208 | 208 |
|
| 209 |
- FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 209 |
+ SchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 210 | 210 |
SchroDecoder *decoder = p_schro_params->decoder; |
| 211 | 211 |
AVPicture *picture = data; |
| 212 | 212 |
SchroBuffer *enc_buf; |
| ... | ... |
@@ -214,11 +214,11 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 214 | 214 |
int state; |
| 215 | 215 |
int go = 1; |
| 216 | 216 |
int outer = 1; |
| 217 |
- FfmpegSchroParseUnitContext parse_ctx; |
|
| 217 |
+ SchroParseUnitContext parse_ctx; |
|
| 218 | 218 |
|
| 219 | 219 |
*data_size = 0; |
| 220 | 220 |
|
| 221 |
- FfmpegSchroParseContextInit(&parse_ctx, buf, buf_size); |
|
| 221 |
+ SchroParseContextInit(&parse_ctx, buf, buf_size); |
|
| 222 | 222 |
if (!buf_size) {
|
| 223 | 223 |
if (!p_schro_params->eos_signalled) {
|
| 224 | 224 |
state = schro_decoder_push_end_of_stream(decoder); |
| ... | ... |
@@ -228,7 +228,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 228 | 228 |
|
| 229 | 229 |
/* Loop through all the individual parse units in the input buffer */ |
| 230 | 230 |
do {
|
| 231 |
- if ((enc_buf = FfmpegFindNextSchroParseUnit(&parse_ctx))) {
|
|
| 231 |
+ if ((enc_buf = FindNextSchroParseUnit(&parse_ctx))) {
|
|
| 232 | 232 |
/* Push buffer into decoder. */ |
| 233 | 233 |
if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) && |
| 234 | 234 |
SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0) |
| ... | ... |
@@ -314,7 +314,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, |
| 314 | 314 |
|
| 315 | 315 |
static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext) |
| 316 | 316 |
{
|
| 317 |
- FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 317 |
+ SchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 318 | 318 |
/* Free the decoder. */ |
| 319 | 319 |
schro_decoder_free(p_schro_params->decoder); |
| 320 | 320 |
av_freep(&p_schro_params->format); |
| ... | ... |
@@ -332,7 +332,7 @@ static void libschroedinger_flush(AVCodecContext *avccontext) |
| 332 | 332 |
{
|
| 333 | 333 |
/* Got a seek request. Free the decoded frames queue and then reset |
| 334 | 334 |
* the decoder */ |
| 335 |
- FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 335 |
+ SchroDecoderParams *p_schro_params = avccontext->priv_data; |
|
| 336 | 336 |
|
| 337 | 337 |
/* Free data in the output frame queue. */ |
| 338 | 338 |
ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue, |
| ... | ... |
@@ -348,7 +348,7 @@ AVCodec ff_libschroedinger_decoder = {
|
| 348 | 348 |
.name = "libschroedinger", |
| 349 | 349 |
.type = AVMEDIA_TYPE_VIDEO, |
| 350 | 350 |
.id = CODEC_ID_DIRAC, |
| 351 |
- .priv_data_size = sizeof(FfmpegSchroDecoderParams), |
|
| 351 |
+ .priv_data_size = sizeof(SchroDecoderParams), |
|
| 352 | 352 |
.init = libschroedinger_decode_init, |
| 353 | 353 |
.close = libschroedinger_decode_close, |
| 354 | 354 |
.decode = libschroedinger_decode_frame, |
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
|
| 42 | 42 |
|
| 43 | 43 |
/** libschroedinger encoder private data */ |
| 44 |
-typedef struct FfmpegSchroEncoderParams {
|
|
| 44 |
+typedef struct SchroEncoderParams {
|
|
| 45 | 45 |
/** Schroedinger video format */ |
| 46 | 46 |
SchroVideoFormat *format; |
| 47 | 47 |
|
| ... | ... |
@@ -64,31 +64,31 @@ typedef struct FfmpegSchroEncoderParams {
|
| 64 | 64 |
int enc_buf_size; |
| 65 | 65 |
|
| 66 | 66 |
/** queue storing encoded frames */ |
| 67 |
- FfmpegDiracSchroQueue enc_frame_queue; |
|
| 67 |
+ DiracSchroQueue enc_frame_queue; |
|
| 68 | 68 |
|
| 69 | 69 |
/** end of sequence signalled */ |
| 70 | 70 |
int eos_signalled; |
| 71 | 71 |
|
| 72 | 72 |
/** end of sequence pulled */ |
| 73 | 73 |
int eos_pulled; |
| 74 |
-} FfmpegSchroEncoderParams; |
|
| 74 |
+} SchroEncoderParams; |
|
| 75 | 75 |
|
| 76 | 76 |
/** |
| 77 | 77 |
* Works out Schro-compatible chroma format. |
| 78 | 78 |
*/ |
| 79 | 79 |
static int SetSchroChromaFormat(AVCodecContext *avccontext) |
| 80 | 80 |
{
|
| 81 |
- int num_formats = sizeof(ffmpeg_schro_pixel_format_map) / |
|
| 82 |
- sizeof(ffmpeg_schro_pixel_format_map[0]); |
|
| 81 |
+ int num_formats = sizeof(schro_pixel_format_map) / |
|
| 82 |
+ sizeof(schro_pixel_format_map[0]); |
|
| 83 | 83 |
int idx; |
| 84 | 84 |
|
| 85 |
- FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
|
| 85 |
+ SchroEncoderParams *p_schro_params = avccontext->priv_data; |
|
| 86 | 86 |
|
| 87 | 87 |
for (idx = 0; idx < num_formats; ++idx) {
|
| 88 |
- if (ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt == |
|
| 88 |
+ if (schro_pixel_format_map[idx].ff_pix_fmt == |
|
| 89 | 89 |
avccontext->pix_fmt) {
|
| 90 | 90 |
p_schro_params->format->chroma_format = |
| 91 |
- ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt; |
|
| 91 |
+ schro_pixel_format_map[idx].schro_pix_fmt; |
|
| 92 | 92 |
return 0; |
| 93 | 93 |
} |
| 94 | 94 |
} |
| ... | ... |
@@ -102,7 +102,7 @@ static int SetSchroChromaFormat(AVCodecContext *avccontext) |
| 102 | 102 |
|
| 103 | 103 |
static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 104 | 104 |
{
|
| 105 |
- FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
|
| 105 |
+ SchroEncoderParams *p_schro_params = avccontext->priv_data; |
|
| 106 | 106 |
SchroVideoFormatEnum preset; |
| 107 | 107 |
|
| 108 | 108 |
/* Initialize the libraries that libschroedinger depends on. */ |
| ... | ... |
@@ -238,7 +238,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) |
| 238 | 238 |
static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext, |
| 239 | 239 |
void *in_data) |
| 240 | 240 |
{
|
| 241 |
- FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
|
| 241 |
+ SchroEncoderParams *p_schro_params = avccontext->priv_data; |
|
| 242 | 242 |
SchroFrame *in_frame; |
| 243 | 243 |
/* Input line size may differ from what the codec supports. Especially |
| 244 | 244 |
* when transcoding from one format to another. So use avpicture_layout |
| ... | ... |
@@ -256,7 +256,7 @@ static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext, |
| 256 | 256 |
|
| 257 | 257 |
static void SchroedingerFreeFrame(void *data) |
| 258 | 258 |
{
|
| 259 |
- FfmpegDiracSchroEncodedFrame *enc_frame = data; |
|
| 259 |
+ DiracSchroEncodedFrame *enc_frame = data; |
|
| 260 | 260 |
|
| 261 | 261 |
av_freep(&(enc_frame->p_encbuf)); |
| 262 | 262 |
av_free(enc_frame); |
| ... | ... |
@@ -267,9 +267,9 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 267 | 267 |
int buf_size, void *data) |
| 268 | 268 |
{
|
| 269 | 269 |
int enc_size = 0; |
| 270 |
- FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
|
| 270 |
+ SchroEncoderParams *p_schro_params = avccontext->priv_data; |
|
| 271 | 271 |
SchroEncoder *encoder = p_schro_params->encoder; |
| 272 |
- struct FfmpegDiracSchroEncodedFrame* p_frame_output = NULL; |
|
| 272 |
+ struct DiracSchroEncodedFrame *p_frame_output = NULL; |
|
| 273 | 273 |
int go = 1; |
| 274 | 274 |
SchroBuffer *enc_buf; |
| 275 | 275 |
int presentation_frame; |
| ... | ... |
@@ -328,7 +328,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 328 | 328 |
} |
| 329 | 329 |
|
| 330 | 330 |
/* Create output frame. */ |
| 331 |
- p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame)); |
|
| 331 |
+ p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame)); |
|
| 332 | 332 |
/* Set output data. */ |
| 333 | 333 |
p_frame_output->size = p_schro_params->enc_buf_size; |
| 334 | 334 |
p_frame_output->p_encbuf = p_schro_params->enc_buf; |
| ... | ... |
@@ -400,8 +400,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, |
| 400 | 400 |
|
| 401 | 401 |
static int libschroedinger_encode_close(AVCodecContext *avccontext) |
| 402 | 402 |
{
|
| 403 |
- |
|
| 404 |
- FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; |
|
| 403 |
+ SchroEncoderParams *p_schro_params = avccontext->priv_data; |
|
| 405 | 404 |
|
| 406 | 405 |
/* Close the encoder. */ |
| 407 | 406 |
schro_encoder_free(p_schro_params->encoder); |
| ... | ... |
@@ -426,7 +425,7 @@ AVCodec ff_libschroedinger_encoder = {
|
| 426 | 426 |
.name = "libschroedinger", |
| 427 | 427 |
.type = AVMEDIA_TYPE_VIDEO, |
| 428 | 428 |
.id = CODEC_ID_DIRAC, |
| 429 |
- .priv_data_size = sizeof(FfmpegSchroEncoderParams), |
|
| 429 |
+ .priv_data_size = sizeof(SchroEncoderParams), |
|
| 430 | 430 |
.init = libschroedinger_encode_init, |
| 431 | 431 |
.encode = libschroedinger_encode_frame, |
| 432 | 432 |
.close = libschroedinger_encode_close, |