* qatar/master: swscale: Fix stack alignment for SSE avcodec: move some AVCodecContext fields to an internal struct. avcodec: use av_opt_set() instead of deprecated av_set_string3() avcodec: fix some const warnings avcodec: remove pointless AVOption, internal_buffer_count imgutils: Fix illegal read. Conflicts: doc/APIchanges libavcodec/avcodec.h libavcodec/version.h
Unified · Split
| @@ -19,6 +19,14 @@ API changes, most recent first: · 18 unmodified lines | |||
| 19 | 2011-10-20 - b35e9e1 - lavu 51.22.0 | 19 | 2011-10-20 - b35e9e1 - lavu 51.22.0 |
| 20 | Add av_strtok() to avstring.h. | 20 | Add av_strtok() to avstring.h. |
| 21 | 21 | ||
| 22 | 2011-xx-xx - xxxxxxx - lavc 53.21.0 | ||
| 23 | Move some AVCodecContext fields to a new private struct, AVCodecInternal, | ||
| 24 | which is accessed from a new field, AVCodecContext.internal. | ||
| 25 | - fields moved: | ||
| 26 | AVCodecContext.internal_buffer --> AVCodecInternal.buffer | ||
| 27 | AVCodecContext.internal_buffer_count --> AVCodecInternal.buffer_count | ||
| 28 | AVCodecContext.is_copy --> AVCodecInternal.is_copy | ||
| 29 | |||
| 22 | 2011-11-13 - lavf 53.15.0 | 30 | 2011-11-13 - lavf 53.15.0 |
| 23 | New interrupt callback API, allowing per-AVFormatContext/AVIOContext | 31 | New interrupt callback API, allowing per-AVFormatContext/AVIOContext |
| 24 | interrupt callbacks. | 32 | interrupt callbacks. |
| @@ -1214,6 +1214,8 @@ typedef struct AVFrame { · 1213 unmodified lines | |||
| 1214 | 1214 | ||
| 1215 | } AVFrame; | 1215 | } AVFrame; |
| 1216 | 1216 | ||
| 1217 | struct AVCodecInternal; | ||
| 1218 | |||
| 1217 | /** | 1219 | /** |
| 1218 | * main external API structure. | 1220 | * main external API structure. |
| 1219 | * New fields can be added to the end with minor version bumps. | 1221 | * New fields can be added to the end with minor version bumps. |
| @@ -2041,17 +2043,21 @@ typedef struct AVCodecContext { · 821 unmodified lines | |||
| 2041 | */ | 2043 | */ |
| 2042 | int color_table_id; | 2044 | int color_table_id; |
| 2043 | 2045 | ||
| 2046 | #if FF_API_INTERNAL_CONTEXT | ||
| 2044 | /** | 2047 | /** |
| 2045 | * internal_buffer count | 2048 | * internal_buffer count |
| 2046 | * Don't touch, used by libavcodec default_get_buffer(). | 2049 | * Don't touch, used by libavcodec default_get_buffer(). |
| 2050 | * @deprecated this field was moved to an internal context | ||
| 2047 | */ | 2051 | */ |
| 2048 | int internal_buffer_count; | 2052 | attribute_deprecated int internal_buffer_count; |
| 2049 | 2053 | ||
| 2050 | /** | 2054 | /** |
| 2051 | * internal_buffers | 2055 | * internal_buffers |
| 2052 | * Don't touch, used by libavcodec default_get_buffer(). | 2056 | * Don't touch, used by libavcodec default_get_buffer(). |
| 2057 | * @deprecated this field was moved to an internal context | ||
| 2053 | */ | 2058 | */ |
| 2054 | void *internal_buffer; | 2059 | attribute_deprecated void *internal_buffer; |
| 2060 | #endif | ||
| 2055 | 2061 | ||
| 2056 | /** | 2062 | /** |
| 2057 | * Global quality for codecs which cannot change it per frame. | 2063 | * Global quality for codecs which cannot change it per frame. |
| @@ -2937,14 +2943,18 @@ typedef struct AVCodecContext { · 879 unmodified lines | |||
| 2937 | */ | 2943 | */ |
| 2938 | AVPacket *pkt; | 2944 | AVPacket *pkt; |
| 2939 | 2945 | ||
| 2946 | #if FF_API_INTERNAL_CONTEXT | ||
| 2940 | /** | 2947 | /** |
| 2941 | * Whether this is a copy of the context which had init() called on it. | 2948 | * Whether this is a copy of the context which had init() called on it. |
| 2942 | * This is used by multithreading - shared tables and picture pointers | 2949 | * This is used by multithreading - shared tables and picture pointers |
| 2943 | * should be freed from the original context only. | 2950 | * should be freed from the original context only. |
| 2944 | * - encoding: Set by libavcodec. | 2951 | * - encoding: Set by libavcodec. |
| 2945 | * - decoding: Set by libavcodec. | 2952 | * - decoding: Set by libavcodec. |
| 2953 | * | ||
| 2954 | * @deprecated this field has been moved to an internal context | ||
| 2946 | */ | 2955 | */ |
| 2947 | int is_copy; | 2956 | attribute_deprecated int is_copy; |
| 2957 | #endif | ||
| 2948 | 2958 | ||
| 2949 | /** | 2959 | /** |
| 2950 | * Which multithreading methods to use. | 2960 | * Which multithreading methods to use. |
| @@ -3013,6 +3023,14 @@ typedef struct AVCodecContext { · 62 unmodified lines | |||
| 3013 | #define AV_EF_COMPLIANT (1<<17) | 3023 | #define AV_EF_COMPLIANT (1<<17) |
| 3014 | #define AV_EF_AGGRESSIVE (1<<18) | 3024 | #define AV_EF_AGGRESSIVE (1<<18) |
| 3015 | 3025 | ||
| 3026 | /** | ||
| 3027 | * Private context used for internal data. | ||
| 3028 | * | ||
| 3029 | * Unlike priv_data, this is not codec-specific. It is used in general | ||
| 3030 | * libavcodec functions. | ||
| 3031 | */ | ||
| 3032 | struct AVCodecInternal *internal; | ||
| 3033 | |||
| 3016 | /** | 3034 | /** |
| 3017 | * Current statistics for PTS correction. | 3035 | * Current statistics for PTS correction. |
| 3018 | * - decoding: maintained and used by libavcodec, not intended to be used by user apps | 3036 | * - decoding: maintained and used by libavcodec, not intended to be used by user apps |
| @@ -1205,7 +1205,8 @@ static void copy_parameter_set(void **to, void **from, int count, int size) · 1204 unmodified lines | |||
| 1205 | static int decode_init_thread_copy(AVCodecContext *avctx){ | 1205 | static int decode_init_thread_copy(AVCodecContext *avctx){ |
| 1206 | H264Context *h= avctx->priv_data; | 1206 | H264Context *h= avctx->priv_data; |
| 1207 | 1207 | ||
| 1208 | if (!avctx->is_copy) return 0; | 1208 | if (!avctx->internal->is_copy) |
| 1209 | return 0; | ||
| 1209 | memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); | 1210 | memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); |
| 1210 | memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); | 1211 | memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); |
| 1211 | 1212 | ||
| @@ -25,8 +25,42 @@ · 24 unmodified lines | |||
| 25 | #define AVCODEC_INTERNAL_H | 25 | #define AVCODEC_INTERNAL_H |
| 26 | 26 | ||
| 27 | #include <stdint.h> | 27 | #include <stdint.h> |
| 28 | |||
| 29 | #include "libavutil/pixfmt.h" | ||
| 28 | #include "avcodec.h" | 30 | #include "avcodec.h" |
| 29 | 31 | ||
| 32 | typedef struct InternalBuffer { | ||
| 33 | int last_pic_num; | ||
| 34 | uint8_t *base[4]; | ||
| 35 | uint8_t *data[4]; | ||
| 36 | int linesize[4]; | ||
| 37 | int width; | ||
| 38 | int height; | ||
| 39 | enum PixelFormat pix_fmt; | ||
| 40 | } InternalBuffer; | ||
| 41 | |||
| 42 | typedef struct AVCodecInternal { | ||
| 43 | /** | ||
| 44 | * internal buffer count | ||
| 45 | * used by default get/release/reget_buffer(). | ||
| 46 | */ | ||
| 47 | int buffer_count; | ||
| 48 | |||
| 49 | /** | ||
| 50 | * internal buffers | ||
| 51 | * used by default get/release/reget_buffer(). | ||
| 52 | */ | ||
| 53 | InternalBuffer *buffer; | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Whether the parent AVCodecContext is a copy of the context which had | ||
| 57 | * init() called on it. | ||
| 58 | * This is used by multithreading - shared tables and picture pointers | ||
| 59 | * should be freed from the original context only. | ||
| 60 | */ | ||
| 61 | int is_copy; | ||
| 62 | } AVCodecInternal; | ||
| 63 | |||
| 30 | struct AVCodecDefault { | 64 | struct AVCodecDefault { |
| 31 | const uint8_t *key; | 65 | const uint8_t *key; |
| 32 | const uint8_t *value; | 66 | const uint8_t *value; |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | |||
| 24 | #include <stdint.h> | 24 | #include <stdint.h> |
| 25 | 25 | ||
| 26 | #include "avcodec.h" | 26 | #include "avcodec.h" |
| 27 | #include "internal.h" | ||
| 27 | #include "get_bits.h" | 28 | #include "get_bits.h" |
| 28 | #include "bytestream.h" | 29 | #include "bytestream.h" |
| 29 | #include "dsputil.h" | 30 | #include "dsputil.h" |
| @@ -405,7 +406,8 @@ static av_cold int mimic_decode_end(AVCodecContext *avctx) · 375 unmodified lines | |||
| 405 | 406 | ||
| 406 | av_free(ctx->swap_buf); | 407 | av_free(ctx->swap_buf); |
| 407 | 408 | ||
| 408 | if(avctx->is_copy) return 0; | 409 | if (avctx->internal->is_copy) |
| 410 | return 0; | ||
| 409 | 411 | ||
| 410 | for(i = 0; i < 16; i++) | 412 | for(i = 0; i < 16; i++) |
| 411 | if(ctx->buf_ptrs[i].data[0]) | 413 | if(ctx->buf_ptrs[i].data[0]) |
| @@ -859,7 +859,7 @@ void MPV_common_end(MpegEncContext *s) · 858 unmodified lines | |||
| 859 | av_freep(&s->reordered_input_picture); | 859 | av_freep(&s->reordered_input_picture); |
| 860 | av_freep(&s->dct_offset); | 860 | av_freep(&s->dct_offset); |
| 861 | 861 | ||
| 862 | if(s->picture && !s->avctx->is_copy){ | 862 | if(s->picture && !s->avctx->internal->is_copy){ |
| 863 | for(i=0; i<s->picture_count; i++){ | 863 | for(i=0; i<s->picture_count; i++){ |
| 864 | free_picture(s, &s->picture[i]); | 864 | free_picture(s, &s->picture[i]); |
| 865 | } | 865 | } |
| @@ -330,7 +330,6 @@ static const AVOption options[]={ · 329 unmodified lines | |||
| 330 | {"ibias", "intra quant bias", OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, | 330 | {"ibias", "intra quant bias", OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, |
| 331 | {"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, | 331 | {"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, |
| 332 | {"color_table_id", NULL, OFFSET(color_table_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, | 332 | {"color_table_id", NULL, OFFSET(color_table_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, |
| 333 | {"internal_buffer_count", NULL, OFFSET(internal_buffer_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, | ||
| 334 | {"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, | 333 | {"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, |
| 335 | {"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"}, | 334 | {"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"}, |
| 336 | {"vlc", "variable length coder / huffman coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"}, | 335 | {"vlc", "variable length coder / huffman coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"}, |
| @@ -590,15 +589,15 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ · 253 unmodified lines | |||
| 590 | } | 589 | } |
| 591 | } | 590 | } |
| 592 | if(codec->priv_class){ | 591 | if(codec->priv_class){ |
| 593 | *(AVClass**)s->priv_data= codec->priv_class; | 592 | *(const AVClass**)s->priv_data = codec->priv_class; |
| 594 | av_opt_set_defaults(s->priv_data); | 593 | av_opt_set_defaults(s->priv_data); |
| 595 | } | 594 | } |
| 596 | } | 595 | } |
| 597 | if (codec && codec->defaults) { | 596 | if (codec && codec->defaults) { |
| 598 | int ret; | 597 | int ret; |
| 599 | AVCodecDefault *d = codec->defaults; | 598 | const AVCodecDefault *d = codec->defaults; |
| 600 | while (d->key) { | 599 | while (d->key) { |
| 601 | ret = av_set_string3(s, d->key, d->value, 0, NULL); | 600 | ret = av_opt_set(s, d->key, d->value, 0); |
| 602 | av_assert0(ret >= 0); | 601 | av_assert0(ret >= 0); |
| 603 | d++; | 602 | d++; |
| 604 | } | 603 | } |
| @@ -653,9 +652,9 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) · 48 unmodified lines | |||
| 653 | dest->priv_data = NULL; | 652 | dest->priv_data = NULL; |
| 654 | dest->codec = NULL; | 653 | dest->codec = NULL; |
| 655 | dest->slice_offset = NULL; | 654 | dest->slice_offset = NULL; |
| 656 | dest->internal_buffer = NULL; | ||
| 657 | dest->hwaccel = NULL; | 655 | dest->hwaccel = NULL; |
| 658 | dest->thread_opaque = NULL; | 656 | dest->thread_opaque = NULL; |
| 657 | dest->internal = NULL; | ||
| 659 | 658 | ||
| 660 | /* reallocate values that should be allocated separately */ | 659 | /* reallocate values that should be allocated separately */ |
| 661 | dest->rc_eq = NULL; | 660 | dest->rc_eq = NULL; |
| @@ -679,8 +679,10 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) · 678 unmodified lines | |||
| 679 | pthread_cond_destroy(&p->output_cond); | 679 | pthread_cond_destroy(&p->output_cond); |
| 680 | av_freep(&p->avpkt.data); | 680 | av_freep(&p->avpkt.data); |
| 681 | 681 | ||
| 682 | if (i) | 682 | if (i) { |
| 683 | av_freep(&p->avctx->priv_data); | 683 | av_freep(&p->avctx->priv_data); |
| 684 | av_freep(&p->avctx->internal); | ||
| 685 | } | ||
| 684 | 686 | ||
| 685 | av_freep(&p->avctx); | 687 | av_freep(&p->avctx); |
| 686 | } | 688 | } |
| @@ -734,9 +736,15 @@ static int frame_thread_init(AVCodecContext *avctx) · 47 unmodified lines | |||
| 734 | 736 | ||
| 735 | update_context_from_thread(avctx, copy, 1); | 737 | update_context_from_thread(avctx, copy, 1); |
| 736 | } else { | 738 | } else { |
| 737 | copy->is_copy = 1; | ||
| 738 | copy->priv_data = av_malloc(codec->priv_data_size); | 739 | copy->priv_data = av_malloc(codec->priv_data_size); |
| 739 | memcpy(copy->priv_data, src->priv_data, codec->priv_data_size); | 740 | memcpy(copy->priv_data, src->priv_data, codec->priv_data_size); |
| 741 | copy->internal = av_malloc(sizeof(AVCodecInternal)); | ||
| 742 | if (!copy->internal) { | ||
| 743 | err = AVERROR(ENOMEM); | ||
| 744 | goto error; | ||
| 745 | } | ||
| 746 | *(copy->internal) = *(src->internal); | ||
| 747 | copy->internal->is_copy = 1; | ||
| 740 | 748 | ||
| 741 | if (codec->init_thread_copy) | 749 | if (codec->init_thread_copy) |
| 742 | err = codec->init_thread_copy(copy); | 750 | err = codec->init_thread_copy(copy); |
| @@ -870,8 +878,7 @@ void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) · 127 unmodified lines | |||
| 870 | } | 878 | } |
| 871 | 879 | ||
| 872 | if(avctx->debug & FF_DEBUG_BUFFERS) | 880 | if(avctx->debug & FF_DEBUG_BUFFERS) |
| 873 | av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p, %d buffers used\n", | 881 | av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", f); |
| 874 | f, f->owner->internal_buffer_count); | ||
| 875 | 882 | ||
| 876 | fctx = p->parent; | 883 | fctx = p->parent; |
| 877 | pthread_mutex_lock(&fctx->buffer_mutex); | 884 | pthread_mutex_lock(&fctx->buffer_mutex); |
| @@ -125,15 +125,6 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ · 124 unmodified lines | |||
| 125 | s->height= -((-height)>>s->lowres); | 125 | s->height= -((-height)>>s->lowres); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | typedef struct InternalBuffer{ | ||
| 129 | int last_pic_num; | ||
| 130 | uint8_t *base[4]; | ||
| 131 | uint8_t *data[4]; | ||
| 132 | int linesize[4]; | ||
| 133 | int width, height; | ||
| 134 | enum PixelFormat pix_fmt; | ||
| 135 | }InternalBuffer; | ||
| 136 | |||
| 137 | #define INTERNAL_BUFFER_SIZE (32+1) | 128 | #define INTERNAL_BUFFER_SIZE (32+1) |
| 138 | 129 | ||
| 139 | void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){ | 130 | void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){ |
| @@ -267,32 +258,27 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 127 unmodified lines | |||
| 267 | int h= s->height; | 258 | int h= s->height; |
| 268 | InternalBuffer *buf; | 259 | InternalBuffer *buf; |
| 269 | int *picture_number; | 260 | int *picture_number; |
| 261 | AVCodecInternal *avci = s->internal; | ||
| 270 | 262 | ||
| 271 | if(pic->data[0]!=NULL) { | 263 | if(pic->data[0]!=NULL) { |
| 272 | av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); | 264 | av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); |
| 273 | return -1; | 265 | return -1; |
| 274 | } | 266 | } |
| 275 | if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) { | 267 | if(avci->buffer_count >= INTERNAL_BUFFER_SIZE) { |
| 276 | av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n"); | 268 | av_log(s, AV_LOG_ERROR, "buffer_count overflow (missing release_buffer?)\n"); |
| 277 | return -1; | 269 | return -1; |
| 278 | } | 270 | } |
| 279 | 271 | ||
| 280 | if(av_image_check_size(w, h, 0, s)) | 272 | if(av_image_check_size(w, h, 0, s)) |
| 281 | return -1; | 273 | return -1; |
| 282 | 274 | ||
| 283 | if(s->internal_buffer==NULL){ | 275 | if (!avci->buffer) { |
| 284 | s->internal_buffer= av_mallocz((INTERNAL_BUFFER_SIZE+1)*sizeof(InternalBuffer)); | 276 | avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE+1) * |
| 277 | sizeof(InternalBuffer)); | ||
| 285 | } | 278 | } |
| 286 | #if 0 | ||
| 287 | s->internal_buffer= av_fast_realloc( | ||
| 288 | s->internal_buffer, | ||
| 289 | &s->internal_buffer_size, | ||
| 290 | sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ | ||
| 291 | ); | ||
| 292 | #endif | ||
| 293 | 279 | ||
| 294 | buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; | 280 | buf = &avci->buffer[avci->buffer_count]; |
| 295 | picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE]).last_pic_num; //FIXME ugly hack | 281 | picture_number = &(avci->buffer[INTERNAL_BUFFER_SIZE]).last_pic_num; //FIXME ugly hack |
| 296 | (*picture_number)++; | 282 | (*picture_number)++; |
| 297 | 283 | ||
| 298 | if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ | 284 | if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ |
| @@ -383,7 +369,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 84 unmodified lines | |||
| 383 | pic->data[i]= buf->data[i]; | 369 | pic->data[i]= buf->data[i]; |
| 384 | pic->linesize[i]= buf->linesize[i]; | 370 | pic->linesize[i]= buf->linesize[i]; |
| 385 | } | 371 | } |
| 386 | s->internal_buffer_count++; | 372 | avci->buffer_count++; |
| 387 | 373 | ||
| 388 | if (s->pkt) { | 374 | if (s->pkt) { |
| 389 | pic->pkt_pts = s->pkt->pts; | 375 | pic->pkt_pts = s->pkt->pts; |
| @@ -399,7 +385,8 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 9 unmodified lines | |||
| 399 | pic->format = s->pix_fmt; | 385 | pic->format = s->pix_fmt; |
| 400 | 386 | ||
| 401 | if(s->debug&FF_DEBUG_BUFFERS) | 387 | if(s->debug&FF_DEBUG_BUFFERS) |
| 402 | av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); | 388 | av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d " |
| 389 | "buffers used\n", pic, avci->buffer_count); | ||
| 403 | 390 | ||
| 404 | return 0; | 391 | return 0; |
| 405 | } | 392 | } |
| @@ -407,22 +394,23 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ · 1 unmodified line | |||
| 407 | void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ | 394 | void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ |
| 408 | int i; | 395 | int i; |
| 409 | InternalBuffer *buf, *last; | 396 | InternalBuffer *buf, *last; |
| 397 | AVCodecInternal *avci = s->internal; | ||
| 410 | 398 | ||
| 411 | assert(pic->type==FF_BUFFER_TYPE_INTERNAL); | 399 | assert(pic->type==FF_BUFFER_TYPE_INTERNAL); |
| 412 | assert(s->internal_buffer_count); | 400 | assert(avci->buffer_count); |
| 413 | 401 | ||
| 414 | if(s->internal_buffer){ | 402 | if (avci->buffer) { |
| 415 | buf = NULL; /* avoids warning */ | 403 | buf = NULL; /* avoids warning */ |
| 416 | for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize | 404 | for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize |
| 417 | buf= &((InternalBuffer*)s->internal_buffer)[i]; | 405 | buf = &avci->buffer[i]; |
| 418 | if(buf->data[0] == pic->data[0]) | 406 | if (buf->data[0] == pic->data[0]) |
| 419 | break; | 407 | break; |
| 420 | } | 408 | } |
| 421 | assert(i < s->internal_buffer_count); | 409 | assert(i < avci->buffer_count); |
| 422 | s->internal_buffer_count--; | 410 | avci->buffer_count--; |
| 423 | last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; | 411 | last = &avci->buffer[avci->buffer_count]; |
| 424 | 412 | ||
| 425 | FFSWAP(InternalBuffer, *buf, *last); | 413 | FFSWAP(InternalBuffer, *buf, *last); |
| 426 | } | 414 | } |
| 427 | 415 | ||
| 428 | for(i=0; i<4; i++){ | 416 | for(i=0; i<4; i++){ |
| @@ -432,7 +420,8 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ · 3 unmodified lines | |||
| 432 | //printf("R%X\n", pic->opaque); | 420 | //printf("R%X\n", pic->opaque); |
| 433 | 421 | ||
| 434 | if(s->debug&FF_DEBUG_BUFFERS) | 422 | if(s->debug&FF_DEBUG_BUFFERS) |
| 435 | av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); | 423 | av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d " |
| 424 | "buffers used\n", pic, avci->buffer_count); | ||
| 436 | } | 425 | } |
| 437 | 426 | ||
| 438 | int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ | 427 | int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ |
| @@ -556,6 +545,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD · 117 unmodified lines | |||
| 556 | goto end; | 545 | goto end; |
| 557 | } | 546 | } |
| 558 | 547 | ||
| 548 | avctx->internal = av_mallocz(sizeof(AVCodecInternal)); | ||
| 549 | if (!avctx->internal) { | ||
| 550 | ret = AVERROR(ENOMEM); | ||
| 551 | goto end; | ||
| 552 | } | ||
| 553 | |||
| 559 | if (codec->priv_data_size > 0) { | 554 | if (codec->priv_data_size > 0) { |
| 560 | if(!avctx->priv_data){ | 555 | if(!avctx->priv_data){ |
| 561 | avctx->priv_data = av_mallocz(codec->priv_data_size); | 556 | avctx->priv_data = av_mallocz(codec->priv_data_size); |
| @@ -721,6 +716,7 @@ end: · 159 unmodified lines | |||
| 721 | free_and_end: | 716 | free_and_end: |
| 722 | av_dict_free(&tmp); | 717 | av_dict_free(&tmp); |
| 723 | av_freep(&avctx->priv_data); | 718 | av_freep(&avctx->priv_data); |
| 719 | av_freep(&avctx->internal); | ||
| 724 | avctx->codec= NULL; | 720 | avctx->codec= NULL; |
| 725 | goto end; | 721 | goto end; |
| 726 | } | 722 | } |
| @@ -945,6 +941,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) · 218 unmodified lines | |||
| 945 | avctx->codec->close(avctx); | 941 | avctx->codec->close(avctx); |
| 946 | avcodec_default_free_buffers(avctx); | 942 | avcodec_default_free_buffers(avctx); |
| 947 | avctx->coded_frame = NULL; | 943 | avctx->coded_frame = NULL; |
| 944 | av_freep(&avctx->internal); | ||
| 948 | if (avctx->codec && avctx->codec->priv_class) | 945 | if (avctx->codec && avctx->codec->priv_class) |
| 949 | av_opt_free(avctx->priv_data); | 946 | av_opt_free(avctx->priv_data); |
| 950 | av_opt_free(avctx); | 947 | av_opt_free(avctx); |
| @@ -1223,22 +1220,25 @@ void avcodec_flush_buffers(AVCodecContext *avctx) · 272 unmodified lines | |||
| 1223 | } | 1220 | } |
| 1224 | 1221 | ||
| 1225 | void avcodec_default_free_buffers(AVCodecContext *s){ | 1222 | void avcodec_default_free_buffers(AVCodecContext *s){ |
| 1223 | AVCodecInternal *avci = s->internal; | ||
| 1226 | int i, j; | 1224 | int i, j; |
| 1227 | 1225 | ||
| 1228 | if(s->internal_buffer==NULL) return; | 1226 | if (!avci->buffer) |
| 1227 | return; | ||
| 1229 | 1228 | ||
| 1230 | if (s->internal_buffer_count) | 1229 | if (avci->buffer_count) |
| 1231 | av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n", s->internal_buffer_count); | 1230 | av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n", |
| 1231 | avci->buffer_count); | ||
| 1232 | for(i=0; i<INTERNAL_BUFFER_SIZE; i++){ | 1232 | for(i=0; i<INTERNAL_BUFFER_SIZE; i++){ |
| 1233 | InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i]; | 1233 | InternalBuffer *buf = &avci->buffer[i]; |
| 1234 | for(j=0; j<4; j++){ | 1234 | for(j=0; j<4; j++){ |
| 1235 | av_freep(&buf->base[j]); | 1235 | av_freep(&buf->base[j]); |
| 1236 | buf->data[j]= NULL; | 1236 | buf->data[j]= NULL; |
| 1237 | } | 1237 | } |
| 1238 | } | 1238 | } |
| 1239 | av_freep(&s->internal_buffer); | 1239 | av_freep(&avci->buffer); |
| 1240 | 1240 | ||
| 1241 | s->internal_buffer_count=0; | 1241 | avci->buffer_count=0; |
| 1242 | } | 1242 | } |
| 1243 | 1243 | ||
| 1244 | #if FF_API_OLD_FF_PICT_TYPES | 1244 | #if FF_API_OLD_FF_PICT_TYPES |
| @@ -21,8 +21,8 @@ · 20 unmodified lines | |||
| 21 | #define AVCODEC_VERSION_H | 21 | #define AVCODEC_VERSION_H |
| 22 | 22 | ||
| 23 | #define LIBAVCODEC_VERSION_MAJOR 53 | 23 | #define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 | #define LIBAVCODEC_VERSION_MINOR 35 | 24 | #define LIBAVCODEC_VERSION_MINOR 36 |
| 25 | #define LIBAVCODEC_VERSION_MICRO 1 | 25 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 26 | 26 | ||
| 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 28 | LIBAVCODEC_VERSION_MINOR, \ | 28 | LIBAVCODEC_VERSION_MINOR, \ |
| @@ -104,5 +104,8 @@ · 75 unmodified lines | |||
| 104 | #ifndef FF_API_PARSE_FRAME | 104 | #ifndef FF_API_PARSE_FRAME |
| 105 | #define FF_API_PARSE_FRAME (LIBAVCODEC_VERSION_MAJOR < 54) | 105 | #define FF_API_PARSE_FRAME (LIBAVCODEC_VERSION_MAJOR < 54) |
| 106 | #endif | 106 | #endif |
| 107 | #ifndef FF_API_INTERNAL_CONTEXT | ||
| 108 | #define FF_API_INTERNAL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54) | ||
| 109 | #endif | ||
| 107 | 110 | ||
| 108 | #endif /* AVCODEC_VERSION_H */ | 111 | #endif /* AVCODEC_VERSION_H */ |
| @@ -35,6 +35,7 @@ · 34 unmodified lines | |||
| 35 | 35 | ||
| 36 | #include "libavutil/imgutils.h" | 36 | #include "libavutil/imgutils.h" |
| 37 | #include "avcodec.h" | 37 | #include "avcodec.h" |
| 38 | #include "internal.h" | ||
| 38 | #include "dsputil.h" | 39 | #include "dsputil.h" |
| 39 | #include "get_bits.h" | 40 | #include "get_bits.h" |
| 40 | 41 | ||
| @@ -2011,7 +2012,8 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx) · 1970 unmodified lines | |||
| 2011 | av_free(s->motion_val[1]); | 2012 | av_free(s->motion_val[1]); |
| 2012 | av_free(s->edge_emu_buffer); | 2013 | av_free(s->edge_emu_buffer); |
| 2013 | 2014 | ||
| 2014 | if (avctx->is_copy) return 0; | 2015 | if (avctx->internal->is_copy) |
| 2016 | return 0; | ||
| 2015 | 2017 | ||
| 2016 | for (i = 0; i < 16; i++) { | 2018 | for (i = 0; i < 16; i++) { |
| 2017 | free_vlc(&s->dc_vlc[i]); | 2019 | free_vlc(&s->dc_vlc[i]); |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | #include "libavutil/imgutils.h" | 25 | #include "libavutil/imgutils.h" |
| 26 | #include "avcodec.h" | 26 | #include "avcodec.h" |
| 27 | #include "internal.h" | ||
| 27 | #include "vp8.h" | 28 | #include "vp8.h" |
| 28 | #include "vp8data.h" | 29 | #include "vp8data.h" |
| 29 | #include "rectangle.h" | 30 | #include "rectangle.h" |
| @@ -88,7 +89,7 @@ static void vp8_decode_flush_impl(AVCodecContext *avctx, · 58 unmodified lines | |||
| 88 | VP8Context *s = avctx->priv_data; | 89 | VP8Context *s = avctx->priv_data; |
| 89 | int i; | 90 | int i; |
| 90 | 91 | ||
| 91 | if (!avctx->is_copy) { | 92 | if (!avctx->internal->is_copy) { |
| 92 | for (i = 0; i < 5; i++) | 93 | for (i = 0; i < 5; i++) |
| 93 | if (s->frames[i].data[0]) | 94 | if (s->frames[i].data[0]) |
| 94 | vp8_release_frame(s, &s->frames[i], prefer_delayed_free, can_direct_free); | 95 | vp8_release_frame(s, &s->frames[i], prefer_delayed_free, can_direct_free); |
| @@ -126,7 +126,7 @@ int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh · 125 unmodified lines | |||
| 126 | has_plane[desc->comp[i].plane] = 1; | 126 | has_plane[desc->comp[i].plane] = 1; |
| 127 | 127 | ||
| 128 | total_size = size[0]; | 128 | total_size = size[0]; |
| 129 | for (i = 1; has_plane[i] && i < 4; i++) { | 129 | for (i = 1; i < 4 && has_plane[i]; i++) { |
| 130 | int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; | 130 | int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; |
| 131 | data[i] = data[i-1] + size[i-1]; | 131 | data[i] = data[i-1] + size[i-1]; |
| 132 | h = (height + (1 << s) - 1) >> s; | 132 | h = (height + (1 << s) - 1) >> s; |
| @@ -790,7 +790,7 @@ static int check_image_pointers(const uint8_t * const data[4], enum PixelFormat · 789 unmodified lines | |||
| 790 | * swscale wrapper, so we don't need to export the SwsContext. | 790 | * swscale wrapper, so we don't need to export the SwsContext. |
| 791 | * Assumes planar YUV to be in YUV order instead of YVU. | 791 | * Assumes planar YUV to be in YUV order instead of YVU. |
| 792 | */ | 792 | */ |
| 793 | int sws_scale(struct SwsContext *c, const uint8_t* const srcSlice[], | 793 | int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t* const srcSlice[], |
| 794 | const int srcStride[], int srcSliceY, int srcSliceH, | 794 | const int srcStride[], int srcSliceY, int srcSliceH, |
| 795 | uint8_t* const dst[], const int dstStride[]) | 795 | uint8_t* const dst[], const int dstStride[]) |
| 796 | { | 796 | { |