00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #include "libdirac_libschro.h"
00027
00028 static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
00029 { 640, 480, 24000, 1001},
00030 { 176, 120, 15000, 1001},
00031 { 176, 144, 25, 2 },
00032 { 352, 240, 15000, 1001},
00033 { 352, 288, 25, 2 },
00034 { 704, 480, 15000, 1001},
00035 { 704, 576, 25, 2 },
00036 { 720, 480, 30000, 1001},
00037 { 720, 576, 25, 1 },
00038 { 1280, 720, 60000, 1001},
00039 { 1280, 720, 50, 1 },
00040 { 1920, 1080, 30000, 1001},
00041 { 1920, 1080, 25, 1 },
00042 { 1920, 1080, 60000, 1001},
00043 { 1920, 1080, 50, 1 },
00044 { 2048, 1080, 24, 1 },
00045 { 4096, 2160, 24, 1 },
00046 };
00047
00048 unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext)
00049 {
00050 unsigned int ret_idx = 0;
00051 unsigned int idx;
00052 unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) /
00053 sizeof(ff_dirac_schro_video_format_info[0]);
00054
00055 for (idx = 1; idx < num_formats; ++idx) {
00056 const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
00057 if (avccontext->width == vf->width &&
00058 avccontext->height == vf->height) {
00059 ret_idx = idx;
00060 if (avccontext->time_base.den == vf->frame_rate_num &&
00061 avccontext->time_base.num == vf->frame_rate_denom)
00062 return idx;
00063 }
00064 }
00065 return ret_idx;
00066 }
00067
00068 void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue)
00069 {
00070 queue->p_head = queue->p_tail = NULL;
00071 queue->size = 0;
00072 }
00073
00074 void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
00075 void (*free_func)(void *))
00076 {
00077 while (queue->p_head)
00078 free_func(ff_dirac_schro_queue_pop(queue));
00079 }
00080
00081 int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data)
00082 {
00083 FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
00084
00085 if (!p_new)
00086 return -1;
00087
00088 p_new->data = p_data;
00089
00090 if (!queue->p_head)
00091 queue->p_head = p_new;
00092 else
00093 queue->p_tail->next = p_new;
00094 queue->p_tail = p_new;
00095
00096 ++queue->size;
00097 return 0;
00098 }
00099
00100 void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue)
00101 {
00102 FfmpegDiracSchroQueueElement *top = queue->p_head;
00103
00104 if (top) {
00105 void *data = top->data;
00106 queue->p_head = queue->p_head->next;
00107 --queue->size;
00108 av_freep(&top);
00109 return data;
00110 }
00111
00112 return NULL;
00113 }