void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,
                        Picture *last, int y, int h, int picture_structure,
                        int first_field, int draw_edges, int low_delay,
                        int v_edge_pos, int h_edge_pos)
{
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
    int hshift = desc->log2_chroma_w;
    int vshift = desc->log2_chroma_h;
    const int field_pic = picture_structure != PICT_FRAME;
    if(field_pic){
        h <<= 1;
        y <<= 1;
    }
    if (!avctx->hwaccel &&
        draw_edges &&
        cur->reference &&
        !(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
        int *linesize = cur->f.linesize;
        int sides = 0, edge_h;
        if (y==0) sides |= EDGE_TOP;
        if (y + h >= v_edge_pos)
            sides |= EDGE_BOTTOM;
        edge_h= FFMIN(h, v_edge_pos - y);
        dsp->draw_edges(cur->f.data[0] + y * linesize[0],
                        linesize[0], h_edge_pos, edge_h,
                        EDGE_WIDTH, EDGE_WIDTH, sides);
        dsp->draw_edges(cur->f.data[1] + (y >> vshift) * linesize[1],
                        linesize[1], h_edge_pos >> hshift, edge_h >> vshift,
                        EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);
        dsp->draw_edges(cur->f.data[2] + (y >> vshift) * linesize[2],
                        linesize[2], h_edge_pos >> hshift, edge_h >> vshift,
                        EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);
    }
    h = FFMIN(h, avctx->height - y);
    if(field_pic && first_field && !(avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
    if (avctx->draw_horiz_band) {
        AVFrame *src;
        int offset[AV_NUM_DATA_POINTERS];
        int i;
        if(cur->f.pict_type == AV_PICTURE_TYPE_B || low_delay ||
           (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
            src = &cur->f;
        else if (last)
            src = &last->f;
        else
            return;
        if (cur->f.pict_type == AV_PICTURE_TYPE_B &&
            picture_structure == PICT_FRAME &&
            avctx->codec_id != AV_CODEC_ID_SVQ3) {
            for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
                offset[i] = 0;
        }else{
            offset[0]= y * src->linesize[0];
            offset[1]=
            offset[2]= (y >> vshift) * src->linesize[1];
            for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
                offset[i] = 0;
        }
        emms_c();
        avctx->draw_horiz_band(avctx, src, offset,
                               y, picture_structure, h);
    }
}
['void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,\n                        Picture *last, int y, int h, int picture_structure,\n                        int first_field, int draw_edges, int low_delay,\n                        int v_edge_pos, int h_edge_pos)\n{\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);\n    int hshift = desc->log2_chroma_w;\n    int vshift = desc->log2_chroma_h;\n    const int field_pic = picture_structure != PICT_FRAME;\n    if(field_pic){\n        h <<= 1;\n        y <<= 1;\n    }\n    if (!avctx->hwaccel &&\n        draw_edges &&\n        cur->reference &&\n        !(avctx->flags & CODEC_FLAG_EMU_EDGE)) {\n        int *linesize = cur->f.linesize;\n        int sides = 0, edge_h;\n        if (y==0) sides |= EDGE_TOP;\n        if (y + h >= v_edge_pos)\n            sides |= EDGE_BOTTOM;\n        edge_h= FFMIN(h, v_edge_pos - y);\n        dsp->draw_edges(cur->f.data[0] + y * linesize[0],\n                        linesize[0], h_edge_pos, edge_h,\n                        EDGE_WIDTH, EDGE_WIDTH, sides);\n        dsp->draw_edges(cur->f.data[1] + (y >> vshift) * linesize[1],\n                        linesize[1], h_edge_pos >> hshift, edge_h >> vshift,\n                        EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);\n        dsp->draw_edges(cur->f.data[2] + (y >> vshift) * linesize[2],\n                        linesize[2], h_edge_pos >> hshift, edge_h >> vshift,\n                        EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);\n    }\n    h = FFMIN(h, avctx->height - y);\n    if(field_pic && first_field && !(avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;\n    if (avctx->draw_horiz_band) {\n        AVFrame *src;\n        int offset[AV_NUM_DATA_POINTERS];\n        int i;\n        if(cur->f.pict_type == AV_PICTURE_TYPE_B || low_delay ||\n           (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))\n            src = &cur->f;\n        else if (last)\n            src = &last->f;\n        else\n            return;\n        if (cur->f.pict_type == AV_PICTURE_TYPE_B &&\n            picture_structure == PICT_FRAME &&\n            avctx->codec_id != AV_CODEC_ID_SVQ3) {\n            for (i = 0; i < AV_NUM_DATA_POINTERS; i++)\n                offset[i] = 0;\n        }else{\n            offset[0]= y * src->linesize[0];\n            offset[1]=\n            offset[2]= (y >> vshift) * src->linesize[1];\n            for (i = 3; i < AV_NUM_DATA_POINTERS; i++)\n                offset[i] = 0;\n        }\n        emms_c();\n        avctx->draw_horiz_band(avctx, src, offset,\n                               y, picture_structure, h);\n    }\n}', 'const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)\n{\n    if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)\n        return NULL;\n    return &av_pix_fmt_descriptors[pix_fmt];\n}']