Support filters and decoders that dont support negative linesizes.
This patch is based on work by stefano. Originally committed as revision 26108 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		
							parent
							
								
									9e99f84f7d
								
							
						
					
					
						commit
						0ccabeeaef
					
				
							
								
								
									
										3
									
								
								ffplay.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								ffplay.c
									
									
									
									
									
								
							| @ -1616,6 +1616,9 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) | |||||||
|     int i, w, h, stride[4]; |     int i, w, h, stride[4]; | ||||||
|     unsigned edge; |     unsigned edge; | ||||||
| 
 | 
 | ||||||
|  |     if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES) | ||||||
|  |         perms |= AV_PERM_NEG_LINESIZES; | ||||||
|  | 
 | ||||||
|     if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) { |     if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) { | ||||||
|         if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ; |         if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ; | ||||||
|         if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE; |         if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE; | ||||||
|  | |||||||
| @ -197,12 +197,13 @@ int avfilter_config_links(AVFilterContext *filter) | |||||||
| 
 | 
 | ||||||
| char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms) | char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms) | ||||||
| { | { | ||||||
|     snprintf(buf, buf_size, "%s%s%s%s%s", |     snprintf(buf, buf_size, "%s%s%s%s%s%s", | ||||||
|              perms & AV_PERM_READ      ? "r" : "", |              perms & AV_PERM_READ      ? "r" : "", | ||||||
|              perms & AV_PERM_WRITE     ? "w" : "", |              perms & AV_PERM_WRITE     ? "w" : "", | ||||||
|              perms & AV_PERM_PRESERVE  ? "p" : "", |              perms & AV_PERM_PRESERVE  ? "p" : "", | ||||||
|              perms & AV_PERM_REUSE     ? "u" : "", |              perms & AV_PERM_REUSE     ? "u" : "", | ||||||
|              perms & AV_PERM_REUSE2    ? "U" : ""); |              perms & AV_PERM_REUSE2    ? "U" : "", | ||||||
|  |              perms & AV_PERM_NEG_LINESIZES ? "n" : ""); | ||||||
|     return buf; |     return buf; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -360,15 +361,17 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | |||||||
| { | { | ||||||
|     void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); |     void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); | ||||||
|     AVFilterPad *dst = link->dstpad; |     AVFilterPad *dst = link->dstpad; | ||||||
|  |     int perms = picref->perms; | ||||||
| 
 | 
 | ||||||
|     FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1); |     FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1); | ||||||
| 
 | 
 | ||||||
|     if (!(start_frame = dst->start_frame)) |     if (!(start_frame = dst->start_frame)) | ||||||
|         start_frame = avfilter_default_start_frame; |         start_frame = avfilter_default_start_frame; | ||||||
| 
 | 
 | ||||||
|  |     if (picref->linesize[0] < 0) | ||||||
|  |         perms |= AV_PERM_NEG_LINESIZES; | ||||||
|     /* prepare to copy the picture if it has insufficient permissions */ |     /* prepare to copy the picture if it has insufficient permissions */ | ||||||
|     if ((dst->min_perms & picref->perms) != dst->min_perms || |     if ((dst->min_perms & perms) != dst->min_perms || dst->rej_perms & perms) { | ||||||
|          dst->rej_perms & picref->perms) { |  | ||||||
|         av_log(link->dst, AV_LOG_DEBUG, |         av_log(link->dst, AV_LOG_DEBUG, | ||||||
|                 "frame copy needed (have perms %x, need %x, reject %x)\n", |                 "frame copy needed (have perms %x, need %x, reject %x)\n", | ||||||
|                 picref->perms, |                 picref->perms, | ||||||
|  | |||||||
| @ -87,6 +87,7 @@ typedef struct AVFilterBuffer { | |||||||
| #define AV_PERM_PRESERVE 0x04   ///< nobody else can overwrite the buffer
 | #define AV_PERM_PRESERVE 0x04   ///< nobody else can overwrite the buffer
 | ||||||
| #define AV_PERM_REUSE    0x08   ///< can output the buffer multiple times, with the same contents each time
 | #define AV_PERM_REUSE    0x08   ///< can output the buffer multiple times, with the same contents each time
 | ||||||
| #define AV_PERM_REUSE2   0x10   ///< can output the buffer multiple times, modified each time
 | #define AV_PERM_REUSE2   0x10   ///< can output the buffer multiple times, modified each time
 | ||||||
|  | #define AV_PERM_NEG_LINESIZES 0x20  ///< the buffer requested can have negative linesizes
 | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * Audio specific properties in a reference to an AVFilterBuffer. Since |  * Audio specific properties in a reference to an AVFilterBuffer. Since | ||||||
|  | |||||||
| @ -43,11 +43,13 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, | |||||||
|                                         int w, int h) |                                         int w, int h) | ||||||
| { | { | ||||||
|     FlipContext *flip = link->dst->priv; |     FlipContext *flip = link->dst->priv; | ||||||
|  |     AVFilterBufferRef *picref; | ||||||
|     int i; |     int i; | ||||||
| 
 | 
 | ||||||
|     AVFilterBufferRef *picref = avfilter_get_video_buffer(link->dst->outputs[0], |     if (!(perms & AV_PERM_NEG_LINESIZES)) | ||||||
|                                                        perms, w, h); |         return avfilter_default_get_video_buffer(link, perms, w, h); | ||||||
| 
 | 
 | ||||||
|  |     picref = avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); | ||||||
|     for (i = 0; i < 4; i ++) { |     for (i = 0; i < 4; i ++) { | ||||||
|         int vsub = i == 1 || i == 2 ? flip->vsub : 0; |         int vsub = i == 1 || i == 2 ? flip->vsub : 0; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user