mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 04:26:37 +08:00 
			
		
		
		
	avcodec: cleanup utils.c
This commit is contained in:
		| @@ -47,23 +47,26 @@ | ||||
| #include <limits.h> | ||||
| #include <float.h> | ||||
|  | ||||
| static int volatile entangled_thread_counter=0; | ||||
| static int volatile entangled_thread_counter = 0; | ||||
| static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op); | ||||
| static void *codec_mutex; | ||||
| static void *avformat_mutex; | ||||
|  | ||||
| void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) | ||||
| { | ||||
|     if(min_size < *size) | ||||
|     if (min_size < *size) | ||||
|         return ptr; | ||||
|  | ||||
|     min_size= FFMAX(17*min_size/16 + 32, min_size); | ||||
|     min_size = FFMAX(17 * min_size / 16 + 32, min_size); | ||||
|  | ||||
|     ptr= av_realloc(ptr, min_size); | ||||
|     if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now | ||||
|         min_size= 0; | ||||
|     ptr = av_realloc(ptr, min_size); | ||||
|     /* we could set this to the unmodified min_size but this is safer | ||||
|      * if the user lost the ptr and uses NULL now | ||||
|      */ | ||||
|     if (!ptr) | ||||
|         min_size = 0; | ||||
|  | ||||
|     *size= min_size; | ||||
|     *size = min_size; | ||||
|  | ||||
|     return ptr; | ||||
| } | ||||
| @@ -73,11 +76,12 @@ void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) | ||||
|     void **p = ptr; | ||||
|     if (min_size < *size) | ||||
|         return; | ||||
|     min_size= FFMAX(17*min_size/16 + 32, min_size); | ||||
|     min_size = FFMAX(17 * min_size / 16 + 32, min_size); | ||||
|     av_free(*p); | ||||
|     *p = av_malloc(min_size); | ||||
|     if (!*p) min_size = 0; | ||||
|     *size= min_size; | ||||
|     if (!*p) | ||||
|         min_size = 0; | ||||
|     *size = min_size; | ||||
| } | ||||
|  | ||||
| void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) | ||||
| @@ -98,8 +102,10 @@ static AVCodec *first_avcodec = NULL; | ||||
|  | ||||
| AVCodec *av_codec_next(const AVCodec *c) | ||||
| { | ||||
|     if(c) return c->next; | ||||
|     else  return first_avcodec; | ||||
|     if (c) | ||||
|         return c->next; | ||||
|     else | ||||
|         return first_avcodec; | ||||
| } | ||||
|  | ||||
| static void avcodec_init(void) | ||||
| @@ -128,7 +134,8 @@ void avcodec_register(AVCodec *codec) | ||||
|     AVCodec **p; | ||||
|     avcodec_init(); | ||||
|     p = &first_avcodec; | ||||
|     while (*p != NULL) p = &(*p)->next; | ||||
|     while (*p != NULL) | ||||
|         p = &(*p)->next; | ||||
|     *p          = codec; | ||||
|     codec->next = NULL; | ||||
|  | ||||
| @@ -141,23 +148,24 @@ unsigned avcodec_get_edge_width(void) | ||||
|     return EDGE_WIDTH; | ||||
| } | ||||
|  | ||||
| void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ | ||||
| void avcodec_set_dimensions(AVCodecContext *s, int width, int height) | ||||
| { | ||||
|     s->coded_width  = width; | ||||
|     s->coded_height= height; | ||||
|     s->coded_height = height; | ||||
|     s->width        = width; | ||||
|     s->height       = height; | ||||
| } | ||||
|  | ||||
| #define INTERNAL_BUFFER_SIZE (32+1) | ||||
| #define INTERNAL_BUFFER_SIZE (32 + 1) | ||||
|  | ||||
| void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, | ||||
|                                int linesize_align[AV_NUM_DATA_POINTERS]) | ||||
| { | ||||
|     int i; | ||||
|     int w_align= 1; | ||||
|     int h_align= 1; | ||||
|     int w_align = 1; | ||||
|     int h_align = 1; | ||||
|  | ||||
|     switch(s->pix_fmt){ | ||||
|     switch (s->pix_fmt) { | ||||
|     case PIX_FMT_YUV420P: | ||||
|     case PIX_FMT_YUYV422: | ||||
|     case PIX_FMT_UYVY422: | ||||
| @@ -194,58 +202,62 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, | ||||
|         break; | ||||
|     case PIX_FMT_YUV411P: | ||||
|     case PIX_FMT_UYYVYY411: | ||||
|         w_align=32; | ||||
|         h_align=8; | ||||
|         w_align = 32; | ||||
|         h_align = 8; | ||||
|         break; | ||||
|     case PIX_FMT_YUV410P: | ||||
|         if(s->codec_id == AV_CODEC_ID_SVQ1){ | ||||
|             w_align=64; | ||||
|             h_align=64; | ||||
|         if (s->codec_id == AV_CODEC_ID_SVQ1) { | ||||
|             w_align = 64; | ||||
|             h_align = 64; | ||||
|         } | ||||
|     case PIX_FMT_RGB555: | ||||
|         if(s->codec_id == AV_CODEC_ID_RPZA){ | ||||
|             w_align=4; | ||||
|             h_align=4; | ||||
|         if (s->codec_id == AV_CODEC_ID_RPZA) { | ||||
|             w_align = 4; | ||||
|             h_align = 4; | ||||
|         } | ||||
|     case PIX_FMT_PAL8: | ||||
|     case PIX_FMT_BGR8: | ||||
|     case PIX_FMT_RGB8: | ||||
|         if(s->codec_id == AV_CODEC_ID_SMC){ | ||||
|             w_align=4; | ||||
|             h_align=4; | ||||
|         if (s->codec_id == AV_CODEC_ID_SMC) { | ||||
|             w_align = 4; | ||||
|             h_align = 4; | ||||
|         } | ||||
|         break; | ||||
|     case PIX_FMT_BGR24: | ||||
|         if((s->codec_id == AV_CODEC_ID_MSZH) || (s->codec_id == AV_CODEC_ID_ZLIB)){ | ||||
|             w_align=4; | ||||
|             h_align=4; | ||||
|         if ((s->codec_id == AV_CODEC_ID_MSZH) || | ||||
|             (s->codec_id == AV_CODEC_ID_ZLIB)) { | ||||
|             w_align = 4; | ||||
|             h_align = 4; | ||||
|         } | ||||
|         break; | ||||
|     default: | ||||
|         w_align= 1; | ||||
|         h_align= 1; | ||||
|         w_align = 1; | ||||
|         h_align = 1; | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     *width = FFALIGN(*width , w_align); | ||||
|     *height= FFALIGN(*height, h_align); | ||||
|     *width  = FFALIGN(*width, w_align); | ||||
|     *height = FFALIGN(*height, h_align); | ||||
|     if (s->codec_id == AV_CODEC_ID_H264) | ||||
|         *height+=2; // some of the optimized chroma MC reads one line too much | ||||
|         // some of the optimized chroma MC reads one line too much | ||||
|         *height += 2; | ||||
|  | ||||
|     for (i = 0; i < 4; i++) | ||||
|         linesize_align[i] = STRIDE_ALIGN; | ||||
| } | ||||
|  | ||||
| void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ | ||||
| void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height) | ||||
| { | ||||
|     int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w; | ||||
|     int linesize_align[AV_NUM_DATA_POINTERS]; | ||||
|     int align; | ||||
|  | ||||
|     avcodec_align_dimensions2(s, width, height, linesize_align); | ||||
|     align               = FFMAX(linesize_align[0], linesize_align[3]); | ||||
|     linesize_align[1] <<= chroma_shift; | ||||
|     linesize_align[2] <<= chroma_shift; | ||||
|     align               = FFMAX3(align, linesize_align[1], linesize_align[2]); | ||||
|     *width=FFALIGN(*width, align); | ||||
|     *width              = FFALIGN(*width, align); | ||||
| } | ||||
|  | ||||
| int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, | ||||
| @@ -305,7 +317,7 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||
|     buf = avci->buffer; | ||||
|  | ||||
|     /* if there is a previously-used internal buffer, check its size and | ||||
|        channel count to see if we can reuse it */ | ||||
|      * channel count to see if we can reuse it */ | ||||
|     if (buf->extended_data) { | ||||
|         /* if current buffer is too small, free it */ | ||||
|         if (buf->extended_data[0] && buf_size > buf->audio_data_size) { | ||||
| @@ -316,7 +328,7 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||
|             buf->data[0]       = NULL; | ||||
|         } | ||||
|         /* if number of channels has changed, reset and/or free extended data | ||||
|            pointers but leave data buffer in buf->data[0] for reuse */ | ||||
|          * pointers but leave data buffer in buf->data[0] for reuse */ | ||||
|         if (buf->nb_channels != avctx->channels) { | ||||
|             if (buf->extended_data != buf->data) | ||||
|                 av_free(buf->extended_data); | ||||
| @@ -325,7 +337,7 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||
|     } | ||||
|  | ||||
|     /* if there is no previous buffer or the previous buffer cannot be used | ||||
|        as-is, allocate a new buffer and/or rearrange the channel pointers */ | ||||
|      * as-is, allocate a new buffer and/or rearrange the channel pointers */ | ||||
|     if (!buf->extended_data) { | ||||
|         if (!buf->data[0]) { | ||||
|             if (!(buf->data[0] = av_mallocz(buf_size))) | ||||
| @@ -353,8 +365,10 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||
|  | ||||
|     frame->type = FF_BUFFER_TYPE_INTERNAL; | ||||
|  | ||||
|     if (avctx->pkt) frame->pkt_pts = avctx->pkt->pts; | ||||
|     else            frame->pkt_pts = AV_NOPTS_VALUE; | ||||
|     if (avctx->pkt) | ||||
|         frame->pkt_pts = avctx->pkt->pts; | ||||
|     else | ||||
|         frame->pkt_pts = AV_NOPTS_VALUE; | ||||
|     frame->reordered_opaque = avctx->reordered_opaque; | ||||
|  | ||||
|     frame->sample_rate    = avctx->sample_rate; | ||||
| @@ -371,53 +385,53 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||
| static int video_get_buffer(AVCodecContext *s, AVFrame *pic) | ||||
| { | ||||
|     int i; | ||||
|     int w= s->width; | ||||
|     int h= s->height; | ||||
|     int w = s->width; | ||||
|     int h = s->height; | ||||
|     InternalBuffer *buf; | ||||
|     AVCodecInternal *avci = s->internal; | ||||
|  | ||||
|     if(pic->data[0]!=NULL) { | ||||
|     if (pic->data[0] != NULL) { | ||||
|         av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); | ||||
|         return -1; | ||||
|     } | ||||
|     if(avci->buffer_count >= INTERNAL_BUFFER_SIZE) { | ||||
|     if (avci->buffer_count >= INTERNAL_BUFFER_SIZE) { | ||||
|         av_log(s, AV_LOG_ERROR, "buffer_count overflow (missing release_buffer?)\n"); | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     if(av_image_check_size(w, h, 0, s)) | ||||
|     if (av_image_check_size(w, h, 0, s)) | ||||
|         return -1; | ||||
|  | ||||
|     if (!avci->buffer) { | ||||
|         avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE+1) * | ||||
|         avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE + 1) * | ||||
|                                   sizeof(InternalBuffer)); | ||||
|     } | ||||
|  | ||||
|     buf = &avci->buffer[avci->buffer_count]; | ||||
|  | ||||
|     if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ | ||||
|     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) { | ||||
|         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) { | ||||
|             av_freep(&buf->base[i]); | ||||
|             buf->data[i]= NULL; | ||||
|             buf->data[i] = NULL; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if (!buf->base[0]) { | ||||
|         int h_chroma_shift, v_chroma_shift; | ||||
|         int size[4] = {0}; | ||||
|         int size[4] = { 0 }; | ||||
|         int tmpsize; | ||||
|         int unaligned; | ||||
|         AVPicture picture; | ||||
|         int stride_align[AV_NUM_DATA_POINTERS]; | ||||
|         const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; | ||||
|         const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1 + 1; | ||||
|  | ||||
|         avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); | ||||
|  | ||||
|         avcodec_align_dimensions2(s, &w, &h, stride_align); | ||||
|  | ||||
|         if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ | ||||
|             w+= EDGE_WIDTH*2; | ||||
|             h+= EDGE_WIDTH*2; | ||||
|         if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { | ||||
|             w += EDGE_WIDTH * 2; | ||||
|             h += EDGE_WIDTH * 2; | ||||
|         } | ||||
|  | ||||
|         do { | ||||
| @@ -425,57 +439,57 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) | ||||
|             // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2 | ||||
|             av_image_fill_linesizes(picture.linesize, s->pix_fmt, w); | ||||
|             // increase alignment of w for next try (rhs gives the lowest bit set in w) | ||||
|             w += w & ~(w-1); | ||||
|             w += w & ~(w - 1); | ||||
|  | ||||
|             unaligned = 0; | ||||
|             for (i=0; i<4; i++){ | ||||
|             for (i = 0; i < 4; i++) | ||||
|                 unaligned |= picture.linesize[i] % stride_align[i]; | ||||
|             } | ||||
|         } while (unaligned); | ||||
|  | ||||
|         tmpsize = av_image_fill_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize); | ||||
|         if (tmpsize < 0) | ||||
|             return -1; | ||||
|  | ||||
|         for (i=0; i<3 && picture.data[i+1]; i++) | ||||
|             size[i] = picture.data[i+1] - picture.data[i]; | ||||
|         for (i = 0; i < 3 && picture.data[i + 1]; i++) | ||||
|             size[i] = picture.data[i + 1] - picture.data[i]; | ||||
|         size[i] = tmpsize - (picture.data[i] - picture.data[0]); | ||||
|  | ||||
|         memset(buf->base, 0, sizeof(buf->base)); | ||||
|         memset(buf->data, 0, sizeof(buf->data)); | ||||
|  | ||||
|         for(i=0; i<4 && size[i]; i++){ | ||||
|             const int h_shift= i==0 ? 0 : h_chroma_shift; | ||||
|             const int v_shift= i==0 ? 0 : v_chroma_shift; | ||||
|         for (i = 0; i < 4 && size[i]; i++) { | ||||
|             const int h_shift = i == 0 ? 0 : h_chroma_shift; | ||||
|             const int v_shift = i == 0 ? 0 : v_chroma_shift; | ||||
|  | ||||
|             buf->linesize[i]= picture.linesize[i]; | ||||
|             buf->linesize[i] = picture.linesize[i]; | ||||
|  | ||||
|             buf->base[i]= av_malloc(size[i]+16); //FIXME 16 | ||||
|             if(buf->base[i]==NULL) return -1; | ||||
|             buf->base[i] = av_malloc(size[i] + 16); //FIXME 16 | ||||
|             if (buf->base[i] == NULL) | ||||
|                 return -1; | ||||
|             memset(buf->base[i], 128, size[i]); | ||||
|  | ||||
|             // no edge if EDGE EMU or not planar YUV | ||||
|             if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2]) | ||||
|             if ((s->flags & CODEC_FLAG_EMU_EDGE) || !size[2]) | ||||
|                 buf->data[i] = buf->base[i]; | ||||
|             else | ||||
|                 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (pixel_size*EDGE_WIDTH>>h_shift), stride_align[i]); | ||||
|                 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i] * EDGE_WIDTH >> v_shift) + (pixel_size * EDGE_WIDTH >> h_shift), stride_align[i]); | ||||
|         } | ||||
|         for (; i < AV_NUM_DATA_POINTERS; i++) { | ||||
|             buf->base[i]     = buf->data[i] = NULL; | ||||
|             buf->linesize[i] = 0; | ||||
|         } | ||||
|         if(size[1] && !size[2]) | ||||
|             ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt); | ||||
|         if (size[1] && !size[2]) | ||||
|             ff_set_systematic_pal2((uint32_t *)buf->data[1], s->pix_fmt); | ||||
|         buf->width   = s->width; | ||||
|         buf->height  = s->height; | ||||
|         buf->pix_fmt= s->pix_fmt; | ||||
|         buf->pix_fmt = s->pix_fmt; | ||||
|     } | ||||
|     pic->type= FF_BUFFER_TYPE_INTERNAL; | ||||
|     pic->type = FF_BUFFER_TYPE_INTERNAL; | ||||
|  | ||||
|     for (i = 0; i < AV_NUM_DATA_POINTERS; i++) { | ||||
|         pic->base[i]= buf->base[i]; | ||||
|         pic->data[i]= buf->data[i]; | ||||
|         pic->linesize[i]= buf->linesize[i]; | ||||
|         pic->base[i]     = buf->base[i]; | ||||
|         pic->data[i]     = buf->data[i]; | ||||
|         pic->linesize[i] = buf->linesize[i]; | ||||
|     } | ||||
|     pic->extended_data = pic->data; | ||||
|     avci->buffer_count++; | ||||
| @@ -484,11 +498,13 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) | ||||
|     pic->format              = buf->pix_fmt; | ||||
|     pic->sample_aspect_ratio = s->sample_aspect_ratio; | ||||
|  | ||||
|     if(s->pkt) pic->pkt_pts= s->pkt->pts; | ||||
|     else       pic->pkt_pts= AV_NOPTS_VALUE; | ||||
|     pic->reordered_opaque= s->reordered_opaque; | ||||
|     if (s->pkt) | ||||
|         pic->pkt_pts = s->pkt->pts; | ||||
|     else | ||||
|         pic->pkt_pts = AV_NOPTS_VALUE; | ||||
|     pic->reordered_opaque = s->reordered_opaque; | ||||
|  | ||||
|     if(s->debug&FF_DEBUG_BUFFERS) | ||||
|     if (s->debug & FF_DEBUG_BUFFERS) | ||||
|         av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d " | ||||
|                                 "buffers used\n", pic, avci->buffer_count); | ||||
|  | ||||
| @@ -507,14 +523,15 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||
|     } | ||||
| } | ||||
|  | ||||
| void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ | ||||
| void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic) | ||||
| { | ||||
|     int i; | ||||
|     InternalBuffer *buf, *last; | ||||
|     AVCodecInternal *avci = s->internal; | ||||
|  | ||||
|     assert(s->codec_type == AVMEDIA_TYPE_VIDEO); | ||||
|  | ||||
|     assert(pic->type==FF_BUFFER_TYPE_INTERNAL); | ||||
|     assert(pic->type == FF_BUFFER_TYPE_INTERNAL); | ||||
|     assert(avci->buffer_count); | ||||
|  | ||||
|     if (avci->buffer) { | ||||
| @@ -532,25 +549,25 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ | ||||
|             FFSWAP(InternalBuffer, *buf, *last); | ||||
|     } | ||||
|  | ||||
|     for (i = 0; i < AV_NUM_DATA_POINTERS; i++) { | ||||
|         pic->data[i]=NULL; | ||||
|     for (i = 0; i < AV_NUM_DATA_POINTERS; i++) | ||||
|         pic->data[i] = NULL; | ||||
| //        pic->base[i]=NULL; | ||||
|     } | ||||
| //printf("R%X\n", pic->opaque); | ||||
|      //printf("R%X\n", pic->opaque); | ||||
|  | ||||
|     if(s->debug&FF_DEBUG_BUFFERS) | ||||
|     if (s->debug & FF_DEBUG_BUFFERS) | ||||
|         av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d " | ||||
|                                 "buffers used\n", pic, avci->buffer_count); | ||||
| } | ||||
|  | ||||
| int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ | ||||
| int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic) | ||||
| { | ||||
|     AVFrame temp_pic; | ||||
|     int i; | ||||
|  | ||||
|     assert(s->codec_type == AVMEDIA_TYPE_VIDEO); | ||||
|  | ||||
|     /* If no picture return a new buffer */ | ||||
|     if(pic->data[0] == NULL) { | ||||
|     if (pic->data[0] == NULL) { | ||||
|         /* We will copy from buffer, so must be readable */ | ||||
|         pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; | ||||
|         return s->get_buffer(s, pic); | ||||
| @@ -559,10 +576,12 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ | ||||
|     assert(s->pix_fmt == pic->format); | ||||
|  | ||||
|     /* If internal buffer type return the same buffer */ | ||||
|     if(pic->type == FF_BUFFER_TYPE_INTERNAL) { | ||||
|         if(s->pkt) pic->pkt_pts= s->pkt->pts; | ||||
|         else       pic->pkt_pts= AV_NOPTS_VALUE; | ||||
|         pic->reordered_opaque= s->reordered_opaque; | ||||
|     if (pic->type == FF_BUFFER_TYPE_INTERNAL) { | ||||
|         if (s->pkt) | ||||
|             pic->pkt_pts = s->pkt->pts; | ||||
|         else | ||||
|             pic->pkt_pts = AV_NOPTS_VALUE; | ||||
|         pic->reordered_opaque = s->reordered_opaque; | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
| @@ -570,58 +589,66 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ | ||||
|      * Not internal type and reget_buffer not overridden, emulate cr buffer | ||||
|      */ | ||||
|     temp_pic = *pic; | ||||
|     for(i = 0; i < AV_NUM_DATA_POINTERS; i++) | ||||
|     for (i = 0; i < AV_NUM_DATA_POINTERS; i++) | ||||
|         pic->data[i] = pic->base[i] = NULL; | ||||
|     pic->opaque = NULL; | ||||
|     /* Allocate new frame */ | ||||
|     if (s->get_buffer(s, pic)) | ||||
|         return -1; | ||||
|     /* Copy image data from old buffer to new buffer */ | ||||
|     av_picture_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width, | ||||
|     av_picture_copy((AVPicture *)pic, (AVPicture *)&temp_pic, s->pix_fmt, s->width, | ||||
|                     s->height); | ||||
|     s->release_buffer(s, &temp_pic); // Release old frame | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ | ||||
| int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size) | ||||
| { | ||||
|     int i; | ||||
|  | ||||
|     for(i=0; i<count; i++){ | ||||
|         int r= func(c, (char*)arg + i*size); | ||||
|         if(ret) ret[i]= r; | ||||
|     for (i = 0; i < count; i++) { | ||||
|         int r = func(c, (char *)arg + i * size); | ||||
|         if (ret) | ||||
|             ret[i] = r; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr),void *arg, int *ret, int count){ | ||||
| int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count) | ||||
| { | ||||
|     int i; | ||||
|  | ||||
|     for(i=0; i<count; i++){ | ||||
|         int r= func(c, arg, i, 0); | ||||
|         if(ret) ret[i]= r; | ||||
|     for (i = 0; i < count; i++) { | ||||
|         int r = func(c, arg, i, 0); | ||||
|         if (ret) | ||||
|             ret[i] = r; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt){ | ||||
| enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt) | ||||
| { | ||||
|     while (*fmt != PIX_FMT_NONE && ff_is_hwaccel_pix_fmt(*fmt)) | ||||
|         ++fmt; | ||||
|     return fmt[0]; | ||||
| } | ||||
|  | ||||
| void avcodec_get_frame_defaults(AVFrame *pic){ | ||||
| void avcodec_get_frame_defaults(AVFrame *pic) | ||||
| { | ||||
|     memset(pic, 0, sizeof(AVFrame)); | ||||
|  | ||||
|     pic->pts= AV_NOPTS_VALUE; | ||||
|     pic->key_frame= 1; | ||||
|     pic->sample_aspect_ratio = (AVRational){0, 1}; | ||||
|     pic->pts                 = AV_NOPTS_VALUE; | ||||
|     pic->key_frame           = 1; | ||||
|     pic->sample_aspect_ratio = (AVRational) {0, 1 }; | ||||
|     pic->format              = -1; /* unknown */ | ||||
| } | ||||
|  | ||||
| AVFrame *avcodec_alloc_frame(void){ | ||||
|     AVFrame *pic= av_malloc(sizeof(AVFrame)); | ||||
| AVFrame *avcodec_alloc_frame(void) | ||||
| { | ||||
|     AVFrame *pic = av_malloc(sizeof(AVFrame)); | ||||
|  | ||||
|     if(pic==NULL) return NULL; | ||||
|     if (pic == NULL) | ||||
|         return NULL; | ||||
|  | ||||
|     avcodec_get_frame_defaults(pic); | ||||
|  | ||||
| @@ -661,7 +688,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code | ||||
|     } | ||||
|  | ||||
|     entangled_thread_counter++; | ||||
|     if(entangled_thread_counter != 1){ | ||||
|     if (entangled_thread_counter != 1) { | ||||
|         av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); | ||||
|         ret = -1; | ||||
|         goto end; | ||||
| @@ -674,14 +701,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code | ||||
|     } | ||||
|  | ||||
|     if (codec->priv_data_size > 0) { | ||||
|       if(!avctx->priv_data){ | ||||
|         if (!avctx->priv_data) { | ||||
|             avctx->priv_data = av_mallocz(codec->priv_data_size); | ||||
|             if (!avctx->priv_data) { | ||||
|                 ret = AVERROR(ENOMEM); | ||||
|                 goto end; | ||||
|             } | ||||
|             if (codec->priv_class) { | ||||
|             *(const AVClass**)avctx->priv_data = codec->priv_class; | ||||
|                 *(const AVClass **)avctx->priv_data = codec->priv_class; | ||||
|                 av_opt_set_defaults(avctx->priv_data); | ||||
|             } | ||||
|         } | ||||
| @@ -693,9 +720,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code | ||||
|     if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) | ||||
|         goto free_and_end; | ||||
|  | ||||
|     if(avctx->coded_width && avctx->coded_height) | ||||
|     if (avctx->coded_width && avctx->coded_height) | ||||
|         avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); | ||||
|     else if(avctx->width && avctx->height) | ||||
|     else if (avctx->width && avctx->height) | ||||
|         avcodec_set_dimensions(avctx, avctx->width, avctx->height); | ||||
|  | ||||
|     if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height) | ||||
| @@ -706,7 +733,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code | ||||
|     } | ||||
|  | ||||
|     /* if the decoder init function was already called previously, | ||||
|        free the already allocated subtitle_header before overwriting it */ | ||||
|      * free the already allocated subtitle_header before overwriting it */ | ||||
|     if (av_codec_is_decoder(codec)) | ||||
|         av_freep(&avctx->subtitle_header); | ||||
|  | ||||
| @@ -802,7 +829,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){ | ||||
|     if (avctx->codec->init && !(avctx->active_thread_type & FF_THREAD_FRAME)) { | ||||
|         ret = avctx->codec->init(avctx); | ||||
|         if (ret < 0) { | ||||
|             goto free_and_end; | ||||
| @@ -834,7 +861,7 @@ free_and_end: | ||||
|     av_dict_free(&tmp); | ||||
|     av_freep(&avctx->priv_data); | ||||
|     av_freep(&avctx->internal); | ||||
|     avctx->codec= NULL; | ||||
|     avctx->codec = NULL; | ||||
|     goto end; | ||||
| } | ||||
|  | ||||
| @@ -990,8 +1017,8 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, | ||||
|     } | ||||
|  | ||||
|     /* NOTE: if we add any audio encoders which output non-keyframe packets, | ||||
|              this needs to be moved to the encoders, but for now we can do it | ||||
|              here to simplify things */ | ||||
|      *       this needs to be moved to the encoders, but for now we can do it | ||||
|      *       here to simplify things */ | ||||
|     avpkt->flags |= AV_PKT_FLAG_KEY; | ||||
|  | ||||
|     if (padded_frame) { | ||||
| @@ -1026,7 +1053,7 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, | ||||
|             frame->nb_samples = avctx->frame_size; | ||||
|         } else { | ||||
|             /* if frame_size is not set, the number of samples must be | ||||
|                calculated from the buffer size */ | ||||
|              * calculated from the buffer size */ | ||||
|             int64_t nb_samples; | ||||
|             if (!av_get_bits_per_sample(avctx->codec_id)) { | ||||
|                 av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not " | ||||
| @@ -1042,19 +1069,19 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, | ||||
|         } | ||||
|  | ||||
|         /* it is assumed that the samples buffer is large enough based on the | ||||
|            relevant parameters */ | ||||
|          * relevant parameters */ | ||||
|         samples_size = av_samples_get_buffer_size(NULL, avctx->channels, | ||||
|                                                   frame->nb_samples, | ||||
|                                                   avctx->sample_fmt, 1); | ||||
|         if ((ret = avcodec_fill_audio_frame(frame, avctx->channels, | ||||
|                                             avctx->sample_fmt, | ||||
|                                             (const uint8_t *) samples, | ||||
|                                             (const uint8_t *)samples, | ||||
|                                             samples_size, 1))) | ||||
|             return ret; | ||||
|  | ||||
|         /* fabricate frame pts from sample count. | ||||
|            this is needed because the avcodec_encode_audio() API does not have | ||||
|            a way for the user to provide pts */ | ||||
|          * this is needed because the avcodec_encode_audio() API does not have | ||||
|          * a way for the user to provide pts */ | ||||
|         frame->pts = ff_samples_to_time_base(avctx, | ||||
|                                              avctx->internal->sample_count); | ||||
|         avctx->internal->sample_count += frame->nb_samples; | ||||
| @@ -1082,6 +1109,7 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, | ||||
|  | ||||
|     return ret ? ret : pkt.size; | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #if FF_API_OLD_ENCODE_VIDEO | ||||
| @@ -1091,7 +1119,7 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf | ||||
|     AVPacket pkt; | ||||
|     int ret, got_packet = 0; | ||||
|  | ||||
|     if(buf_size < FF_MIN_BUFFER_SIZE){ | ||||
|     if (buf_size < FF_MIN_BUFFER_SIZE) { | ||||
|         av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); | ||||
|         return -1; | ||||
|     } | ||||
| @@ -1117,6 +1145,7 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf | ||||
|  | ||||
|     return ret ? ret : pkt.size; | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, | ||||
| @@ -1168,11 +1197,11 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, | ||||
|                             const AVSubtitle *sub) | ||||
| { | ||||
|     int ret; | ||||
|     if(sub->start_display_time) { | ||||
|     if (sub->start_display_time) { | ||||
|         av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n"); | ||||
|         return -1; | ||||
|     } | ||||
|     if(sub->num_rects == 0 || !sub->rects) | ||||
|     if (sub->num_rects == 0 || !sub->rects) | ||||
|         return -1; | ||||
|     ret = avctx->codec->encode_sub(avctx, buf, buf_size, sub); | ||||
|     avctx->frame_number++; | ||||
| @@ -1227,21 +1256,21 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi | ||||
| { | ||||
|     int ret; | ||||
|  | ||||
|     *got_picture_ptr= 0; | ||||
|     if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx)) | ||||
|     *got_picture_ptr = 0; | ||||
|     if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx)) | ||||
|         return -1; | ||||
|  | ||||
|     avctx->pkt = avpkt; | ||||
|     apply_param_change(avctx, avpkt); | ||||
|  | ||||
|     if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){ | ||||
|         if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME) | ||||
|     if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { | ||||
|         if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) | ||||
|             ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr, | ||||
|                                          avpkt); | ||||
|         else { | ||||
|             ret = avctx->codec->decode(avctx, picture, got_picture_ptr, | ||||
|                                        avpkt); | ||||
|             picture->pkt_dts= avpkt->dts; | ||||
|             picture->pkt_dts             = avpkt->dts; | ||||
|             picture->sample_aspect_ratio = avctx->sample_aspect_ratio; | ||||
|             picture->width               = avctx->width; | ||||
|             picture->height              = avctx->height; | ||||
| @@ -1252,8 +1281,8 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi | ||||
|  | ||||
|         if (*got_picture_ptr) | ||||
|             avctx->frame_number++; | ||||
|     }else | ||||
|         ret= 0; | ||||
|     } else | ||||
|         ret = 0; | ||||
|  | ||||
|     return ret; | ||||
| } | ||||
| @@ -1303,6 +1332,7 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa | ||||
|     } | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, | ||||
| @@ -1353,8 +1383,7 @@ void avsubtitle_free(AVSubtitle *sub) | ||||
| { | ||||
|     int i; | ||||
|  | ||||
|     for (i = 0; i < sub->num_rects; i++) | ||||
|     { | ||||
|     for (i = 0; i < sub->num_rects; i++) { | ||||
|         av_freep(&sub->rects[i]->pict.data[0]); | ||||
|         av_freep(&sub->rects[i]->pict.data[1]); | ||||
|         av_freep(&sub->rects[i]->pict.data[2]); | ||||
| @@ -1378,7 +1407,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) | ||||
|     } | ||||
|  | ||||
|     entangled_thread_counter++; | ||||
|     if(entangled_thread_counter != 1){ | ||||
|     if (entangled_thread_counter != 1) { | ||||
|         av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); | ||||
|         entangled_thread_counter--; | ||||
|         return -1; | ||||
| @@ -1413,7 +1442,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) | ||||
|  | ||||
| AVCodec *avcodec_find_encoder(enum AVCodecID id) | ||||
| { | ||||
|     AVCodec *p, *experimental=NULL; | ||||
|     AVCodec *p, *experimental = NULL; | ||||
|     p = first_avcodec; | ||||
|     while (p) { | ||||
|         if (av_codec_is_encoder(p) && p->id == id) { | ||||
| @@ -1434,7 +1463,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name) | ||||
|         return NULL; | ||||
|     p = first_avcodec; | ||||
|     while (p) { | ||||
|         if (av_codec_is_encoder(p) && strcmp(name,p->name) == 0) | ||||
|         if (av_codec_is_encoder(p) && strcmp(name, p->name) == 0) | ||||
|             return p; | ||||
|         p = p->next; | ||||
|     } | ||||
| @@ -1460,7 +1489,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name) | ||||
|         return NULL; | ||||
|     p = first_avcodec; | ||||
|     while (p) { | ||||
|         if (av_codec_is_decoder(p) && strcmp(name,p->name) == 0) | ||||
|         if (av_codec_is_decoder(p) && strcmp(name, p->name) == 0) | ||||
|             return p; | ||||
|         p = p->next; | ||||
|     } | ||||
| @@ -1472,7 +1501,7 @@ static int get_bit_rate(AVCodecContext *ctx) | ||||
|     int bit_rate; | ||||
|     int bits_per_sample; | ||||
|  | ||||
|     switch(ctx->codec_type) { | ||||
|     switch (ctx->codec_type) { | ||||
|     case AVMEDIA_TYPE_VIDEO: | ||||
|     case AVMEDIA_TYPE_DATA: | ||||
|     case AVMEDIA_TYPE_SUBTITLE: | ||||
| @@ -1496,11 +1525,11 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta | ||||
|  | ||||
|     for (i = 0; i < 4; i++) { | ||||
|         len = snprintf(buf, buf_size, | ||||
|                        isprint(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF); | ||||
|                        isprint(codec_tag & 0xFF) ? "%c" : "[%d]", codec_tag & 0xFF); | ||||
|         buf        += len; | ||||
|         buf_size    = buf_size > len ? buf_size - len : 0; | ||||
|         ret        += len; | ||||
|         codec_tag>>=8; | ||||
|         codec_tag >>= 8; | ||||
|     } | ||||
|     return ret; | ||||
| } | ||||
| @@ -1526,7 +1555,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) | ||||
|         profile = av_get_profile_name(p, enc->profile); | ||||
|     } else if (enc->codec_id == AV_CODEC_ID_MPEG2TS) { | ||||
|         /* fake mpeg2 transport stream codec (currently not | ||||
|            registered) */ | ||||
|          * registered) */ | ||||
|         codec_name = "mpeg2ts"; | ||||
|     } else if (enc->codec_name[0] != '\0') { | ||||
|         codec_name = enc->codec_name; | ||||
| @@ -1538,7 +1567,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) | ||||
|         codec_name = buf1; | ||||
|     } | ||||
|  | ||||
|     switch(enc->codec_type) { | ||||
|     switch (enc->codec_type) { | ||||
|     case AVMEDIA_TYPE_VIDEO: | ||||
|         snprintf(buf, buf_size, | ||||
|                  "Video: %s%s", | ||||
| @@ -1557,19 +1586,19 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) | ||||
|                      enc->width, enc->height); | ||||
|             if (enc->sample_aspect_ratio.num) { | ||||
|                 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, | ||||
|                           enc->width*enc->sample_aspect_ratio.num, | ||||
|                           enc->height*enc->sample_aspect_ratio.den, | ||||
|                           1024*1024); | ||||
|                           enc->width * enc->sample_aspect_ratio.num, | ||||
|                           enc->height * enc->sample_aspect_ratio.den, | ||||
|                           1024 * 1024); | ||||
|                 snprintf(buf + strlen(buf), buf_size - strlen(buf), | ||||
|                          " [PAR %d:%d DAR %d:%d]", | ||||
|                          enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, | ||||
|                          display_aspect_ratio.num, display_aspect_ratio.den); | ||||
|             } | ||||
|             if(av_log_get_level() >= AV_LOG_DEBUG){ | ||||
|                 int g= av_gcd(enc->time_base.num, enc->time_base.den); | ||||
|             if (av_log_get_level() >= AV_LOG_DEBUG) { | ||||
|                 int g = av_gcd(enc->time_base.num, enc->time_base.den); | ||||
|                 snprintf(buf + strlen(buf), buf_size - strlen(buf), | ||||
|                          ", %d/%d", | ||||
|                      enc->time_base.num/g, enc->time_base.den/g); | ||||
|                          enc->time_base.num / g, enc->time_base.den / g); | ||||
|             } | ||||
|         } | ||||
|         if (encode) { | ||||
| @@ -1636,7 +1665,7 @@ const char *av_get_profile_name(const AVCodec *codec, int profile) | ||||
|     return NULL; | ||||
| } | ||||
|  | ||||
| unsigned avcodec_version( void ) | ||||
| unsigned avcodec_version(void) | ||||
| { | ||||
|     return LIBAVCODEC_VERSION_INT; | ||||
| } | ||||
| @@ -1654,9 +1683,9 @@ const char *avcodec_license(void) | ||||
|  | ||||
| void avcodec_flush_buffers(AVCodecContext *avctx) | ||||
| { | ||||
|     if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME) | ||||
|     if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) | ||||
|         ff_thread_flush(avctx); | ||||
|     else if(avctx->codec->flush) | ||||
|     else if (avctx->codec->flush) | ||||
|         avctx->codec->flush(avctx); | ||||
| } | ||||
|  | ||||
| @@ -1671,16 +1700,16 @@ static void video_free_buffers(AVCodecContext *s) | ||||
|     if (avci->buffer_count) | ||||
|         av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n", | ||||
|                avci->buffer_count); | ||||
|     for(i=0; i<INTERNAL_BUFFER_SIZE; i++){ | ||||
|     for (i = 0; i < INTERNAL_BUFFER_SIZE; i++) { | ||||
|         InternalBuffer *buf = &avci->buffer[i]; | ||||
|         for(j=0; j<4; j++){ | ||||
|         for (j = 0; j < 4; j++) { | ||||
|             av_freep(&buf->base[j]); | ||||
|             buf->data[j]= NULL; | ||||
|             buf->data[j] = NULL; | ||||
|         } | ||||
|     } | ||||
|     av_freep(&avci->buffer); | ||||
|  | ||||
|     avci->buffer_count=0; | ||||
|     avci->buffer_count = 0; | ||||
| } | ||||
|  | ||||
| static void audio_free_buffers(AVCodecContext *avctx) | ||||
| @@ -1716,7 +1745,7 @@ void avcodec_default_free_buffers(AVCodecContext *avctx) | ||||
|  | ||||
| int av_get_exact_bits_per_sample(enum AVCodecID codec_id) | ||||
| { | ||||
|     switch(codec_id){ | ||||
|     switch (codec_id) { | ||||
|     case AV_CODEC_ID_ADPCM_CT: | ||||
|     case AV_CODEC_ID_ADPCM_IMA_APC: | ||||
|     case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: | ||||
| @@ -1923,16 +1952,18 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) | ||||
| } | ||||
|  | ||||
| #if !HAVE_THREADS | ||||
| int ff_thread_init(AVCodecContext *s){ | ||||
| int ff_thread_init(AVCodecContext *s) | ||||
| { | ||||
|     return -1; | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| unsigned int av_xiphlacing(unsigned char *s, unsigned int v) | ||||
| { | ||||
|     unsigned int n = 0; | ||||
|  | ||||
|     while(v >= 0xff) { | ||||
|     while (v >= 0xff) { | ||||
|         *s++ = 0xff; | ||||
|         v -= 0xff; | ||||
|         n++; | ||||
| @@ -1942,9 +1973,10 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v) | ||||
|     return n; | ||||
| } | ||||
|  | ||||
| int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ | ||||
| int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b) | ||||
| { | ||||
|     int i; | ||||
|     for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++); | ||||
|     for (i = 0; i < size && !(tab[i][0] == a && tab[i][1] == b); i++) ; | ||||
|     return i; | ||||
| } | ||||
|  | ||||
| @@ -1991,13 +2023,12 @@ AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel) | ||||
|  | ||||
| AVHWAccel *ff_find_hwaccel(enum AVCodecID codec_id, enum PixelFormat pix_fmt) | ||||
| { | ||||
|     AVHWAccel *hwaccel=NULL; | ||||
|     AVHWAccel *hwaccel = NULL; | ||||
|  | ||||
|     while((hwaccel= av_hwaccel_next(hwaccel))){ | ||||
|         if (   hwaccel->id      == codec_id | ||||
|     while ((hwaccel = av_hwaccel_next(hwaccel))) | ||||
|         if (hwaccel->id == codec_id | ||||
|             && hwaccel->pix_fmt == pix_fmt) | ||||
|             return hwaccel; | ||||
|     } | ||||
|     return NULL; | ||||
| } | ||||
|  | ||||
| @@ -2041,10 +2072,10 @@ int avpriv_unlock_avformat(void) | ||||
|  | ||||
| unsigned int avpriv_toupper4(unsigned int x) | ||||
| { | ||||
|     return     toupper( x     &0xFF) | ||||
|             + (toupper((x>>8 )&0xFF)<<8 ) | ||||
|             + (toupper((x>>16)&0xFF)<<16) | ||||
|             + (toupper((x>>24)&0xFF)<<24); | ||||
|     return toupper(x & 0xFF) | ||||
|            + (toupper((x >> 8) & 0xFF) << 8) | ||||
|            + (toupper((x >> 16) & 0xFF) << 16) | ||||
|            + (toupper((x >> 24) & 0xFF) << 24); | ||||
| } | ||||
|  | ||||
| #if !HAVE_THREADS | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Luca Barbato
					Luca Barbato