mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 20:42:49 +08:00 
			
		
		
		
	lavc: move ff_init_buffer_info() down to ff_get_buffer()
and remove redundant code from ff_get_buffer() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		| @@ -303,35 +303,6 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height) | |||||||
|     *width              = FFALIGN(*width, align); |     *width              = FFALIGN(*width, align); | ||||||
| } | } | ||||||
|  |  | ||||||
| void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame) |  | ||||||
| { |  | ||||||
|     if (s->pkt) { |  | ||||||
|         frame->pkt_pts = s->pkt->pts; |  | ||||||
|         frame->pkt_pos = s->pkt->pos; |  | ||||||
|         frame->pkt_duration = s->pkt->duration; |  | ||||||
|     } else { |  | ||||||
|         frame->pkt_pts = AV_NOPTS_VALUE; |  | ||||||
|         frame->pkt_pos = -1; |  | ||||||
|         frame->pkt_duration = 0; |  | ||||||
|     } |  | ||||||
|     frame->reordered_opaque = s->reordered_opaque; |  | ||||||
|  |  | ||||||
|     switch (s->codec->type) { |  | ||||||
|     case AVMEDIA_TYPE_VIDEO: |  | ||||||
|         frame->width               = s->width; |  | ||||||
|         frame->height              = s->height; |  | ||||||
|         frame->format              = s->pix_fmt; |  | ||||||
|         frame->sample_aspect_ratio = s->sample_aspect_ratio; |  | ||||||
|         break; |  | ||||||
|     case AVMEDIA_TYPE_AUDIO: |  | ||||||
|         frame->sample_rate    = s->sample_rate; |  | ||||||
|         frame->format         = s->sample_fmt; |  | ||||||
|         frame->channel_layout = s->channel_layout; |  | ||||||
|         frame->channels       = s->channels; |  | ||||||
|         break; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, | int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, | ||||||
|                              enum AVSampleFormat sample_fmt, const uint8_t *buf, |                              enum AVSampleFormat sample_fmt, const uint8_t *buf, | ||||||
|                              int buf_size, int align) |                              int buf_size, int align) | ||||||
| @@ -579,26 +550,37 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame) | void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame) | ||||||
| { | { | ||||||
|     switch (avctx->codec_type) { |     if (s->pkt) { | ||||||
|  |         frame->pkt_pts = s->pkt->pts; | ||||||
|  |         frame->pkt_pos = s->pkt->pos; | ||||||
|  |         frame->pkt_duration = s->pkt->duration; | ||||||
|  |     } else { | ||||||
|  |         frame->pkt_pts = AV_NOPTS_VALUE; | ||||||
|  |         frame->pkt_pos = -1; | ||||||
|  |         frame->pkt_duration = 0; | ||||||
|  |     } | ||||||
|  |     frame->reordered_opaque = s->reordered_opaque; | ||||||
|  |  | ||||||
|  |     switch (s->codec->type) { | ||||||
|     case AVMEDIA_TYPE_VIDEO: |     case AVMEDIA_TYPE_VIDEO: | ||||||
|         frame->width               = avctx->width; |         frame->width               = s->width; | ||||||
|         frame->height              = avctx->height; |         frame->height              = s->height; | ||||||
|         frame->format              = avctx->pix_fmt; |         frame->format              = s->pix_fmt; | ||||||
|         frame->sample_aspect_ratio = avctx->sample_aspect_ratio; |         frame->sample_aspect_ratio = s->sample_aspect_ratio; | ||||||
|         break; |         break; | ||||||
|     case AVMEDIA_TYPE_AUDIO: |     case AVMEDIA_TYPE_AUDIO: | ||||||
|         frame->sample_rate    = avctx->sample_rate; |         frame->sample_rate    = s->sample_rate; | ||||||
|         frame->format         = avctx->sample_fmt; |         frame->format         = s->sample_fmt; | ||||||
|         frame->channel_layout = avctx->channel_layout; |         frame->channel_layout = s->channel_layout; | ||||||
|  |         frame->channels       = s->channels; | ||||||
|         break; |         break; | ||||||
|     default: return AVERROR(EINVAL); |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|     frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE; | int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame) | ||||||
|     frame->reordered_opaque = avctx->reordered_opaque; | { | ||||||
|  |  | ||||||
|     ff_init_buffer_info(avctx, frame); |     ff_init_buffer_info(avctx, frame); | ||||||
|  |  | ||||||
|     return avctx->get_buffer(avctx, frame); |     return avctx->get_buffer(avctx, frame); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Niedermayer
					Michael Niedermayer