History

avfilter/vf_sr.c: refine code to use AVPixFmtDescriptor.log2_chroma_h/w

Guo, Yejun committed 6 years ago

Commit f9cb7cf1 parent ac738791 file · +6 −34Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_sr.c+6−34
@@ -176,40 +176,12 @@ static int config_props(AVFilterLink *inlink) · 175 unmodified lines
176 sr_context->sws_slice_h = inlink->h;176 sr_context->sws_slice_h = inlink->h;
177 } else {177 } else {
178 if (inlink->format != AV_PIX_FMT_GRAY8){178 if (inlink->format != AV_PIX_FMT_GRAY8){
179 sws_src_h = sr_context->input.height;179 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
180 sws_src_w = sr_context->input.width;180 sws_src_h = AV_CEIL_RSHIFT(sr_context->input.height, desc->log2_chroma_h);
181 sws_dst_h = sr_context->output.height;181 sws_src_w = AV_CEIL_RSHIFT(sr_context->input.width, desc->log2_chroma_w);
182 sws_dst_w = sr_context->output.width;182 sws_dst_h = AV_CEIL_RSHIFT(sr_context->output.height, desc->log2_chroma_h);
183 183 sws_dst_w = AV_CEIL_RSHIFT(sr_context->output.width, desc->log2_chroma_w);
184 switch (inlink->format){184
185 case AV_PIX_FMT_YUV420P:
186 sws_src_h = AV_CEIL_RSHIFT(sws_src_h, 1);
187 sws_src_w = AV_CEIL_RSHIFT(sws_src_w, 1);
188 sws_dst_h = AV_CEIL_RSHIFT(sws_dst_h, 1);
189 sws_dst_w = AV_CEIL_RSHIFT(sws_dst_w, 1);
190 break;
191 case AV_PIX_FMT_YUV422P:
192 sws_src_w = AV_CEIL_RSHIFT(sws_src_w, 1);
193 sws_dst_w = AV_CEIL_RSHIFT(sws_dst_w, 1);
194 break;
195 case AV_PIX_FMT_YUV444P:
196 break;
197 case AV_PIX_FMT_YUV410P:
198 sws_src_h = AV_CEIL_RSHIFT(sws_src_h, 2);
199 sws_src_w = AV_CEIL_RSHIFT(sws_src_w, 2);
200 sws_dst_h = AV_CEIL_RSHIFT(sws_dst_h, 2);
201 sws_dst_w = AV_CEIL_RSHIFT(sws_dst_w, 2);
202 break;
203 case AV_PIX_FMT_YUV411P:
204 sws_src_w = AV_CEIL_RSHIFT(sws_src_w, 2);
205 sws_dst_w = AV_CEIL_RSHIFT(sws_dst_w, 2);
206 break;
207 default:
208 av_log(context, AV_LOG_ERROR,
209 "could not create SwsContext for scaling for given input pixel format: %s\n",
210 av_get_pix_fmt_name(inlink->format));
211 return AVERROR(EIO);
212 }
213 sr_context->sws_contexts[0] = sws_getContext(sws_src_w, sws_src_h, AV_PIX_FMT_GRAY8,185 sr_context->sws_contexts[0] = sws_getContext(sws_src_w, sws_src_h, AV_PIX_FMT_GRAY8,
214 sws_dst_w, sws_dst_h, AV_PIX_FMT_GRAY8,186 sws_dst_w, sws_dst_h, AV_PIX_FMT_GRAY8,
215 SWS_BICUBIC, NULL, NULL, NULL);187 SWS_BICUBIC, NULL, NULL, NULL);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t