Recherche avancée

Médias (0)

Mot : - Tags -/diogene

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (112)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (13477)

  • How to convert AVFrame to cv::cuda::GpuMat

    29 mai 2021, par Bump

    After I decode a frame use FFmpeg(Hardware decoding like this : https://github.com/FFmpeg/FFmpeg/blob/release/4.1/doc/examples/hw_decode.c)the decoded frames still remain on GPU memory. How can I convert AVFrame to GpuMat ?

    


    I tried to do it using this code :

    


    __global__ void NV12ToBGRkernel(uchar* ydata, uchar* uvdata, int ywidth, int uvwidth, cv::cuda::PtrStepSz<uchar3> rgbFrame) {&#xA;    int i = threadIdx.x &#x2B; blockIdx.x * blockDim.x;      &#xA;    int j = threadIdx.y &#x2B; blockIdx.y * blockDim.y;    &#xA;&#xA;    int indexY = j * ywidth &#x2B; i;&#xA;    int id2 = i % 2;&#xA;    int indexU = j / 2 * uvwidth &#x2B; i - id2;&#xA;    int indexV = indexU &#x2B; 1;&#xA;&#xA;    if (j &lt; rgbFrame.rows &amp;&amp; i &lt; rgbFrame.cols) {&#xA;        uchar Y = ydata[indexY];&#xA;        uchar U = uvdata[indexU];&#xA;        uchar V = uvdata[indexV];&#xA;        int R = Y &#x2B; 1.402*(V - 128);&#xA;        int G = Y - 0.34414*(U - 128) - 0.71414*(V - 128);&#xA;        int B = Y &#x2B; 1.772*(U - 128);&#xA;&#xA;        if (R &lt; 0)&#xA;            R = 0;&#xA;        if (G &lt; 0)&#xA;            G = 0;&#xA;        if (B &lt; 0)&#xA;            B = 0;&#xA;&#xA;        rgbFrame(j, i).x = (B>255) ? 255 : (uchar)B;&#xA;        rgbFrame(j, i).y = (G>255) ? 255 : (uchar)G;&#xA;        rgbFrame(j, i).z = (R>255) ? 255 : (uchar)R;&#xA;    }&#xA;    return;&#xA;}&#xA;&#xA;extern "C" int cuda_NV12ToBGR(AVFrame *frame, cv::cuda::GpuMat* out) {&#xA;    int width = out->cols;&#xA;    int height = out->rows;&#xA;    int byteCount = out->elemSize();&#xA;    int bx = ceil((double)width / BLOCKDIM_X);  &#xA;    int by = ceil((double)height / BLOCKDIM_Y);&#xA;&#xA;    if (bx > GRIDDIM_X) bx = GRIDDIM_X;&#xA;    if (by > GRIDDIM_Y) by = GRIDDIM_Y;&#xA;&#xA;    dim3 grid(bx, by);&#xA;    dim3 block(BLOCKDIM_X, BLOCKDIM_Y);&#xA;&#xA;    uchar* ydata = frame->data[0];&#xA;    uchar* uvdata = frame->data[1];&#xA;    int ywidth = frame->linesize[0];&#xA;    int uvwidth = frame->linesize[1];&#xA;&#xA;    NV12ToBGRkernel &lt;&lt; > >(ydata, uvdata, ywidth, uvwidth, *out);&#xA;&#xA;    cudaDeviceSynchronize();&#xA;    gpuErrchk(cudaPeekAtLastError());&#xA;    return 1;&#xA;}&#xA;</uchar3>

    &#xA;

    Using the above code I can get a GpuMat, but after I download the GpuMat to Mat and imshow it, I found the decode frames to be the same sometimes (two adjacent frames),and if I use av_hwframe_transfer_data bofore, then convert AVFrame to GpuMat ,it won't happen again. When I checked in the source code in av_hwframe_transfer_data, I found this :

    &#xA;

    static int cuda_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,&#xA;                                   const AVFrame *src) {&#xA;    CUDAFramesContext       *priv = ctx->internal->priv;&#xA;    AVHWDeviceContext *device_ctx = ctx->device_ctx;&#xA;    AVCUDADeviceContext    *hwctx = device_ctx->hwctx;&#xA;    CudaFunctions             *cu = hwctx->internal->cuda_dl;&#xA;&#xA;    CUcontext dummy;&#xA;    int i, ret;&#xA;&#xA;    ret = CHECK_CU(cu->cuCtxPushCurrent(hwctx->cuda_ctx));&#xA;    if (ret &lt; 0)&#xA;        return ret;&#xA;&#xA;    for (i = 0; i &lt; FF_ARRAY_ELEMS(src->data) &amp;&amp; src->data[i]; i&#x2B;&#x2B;) {&#xA;        CUDA_MEMCPY2D cpy = {&#xA;            .srcMemoryType = CU_MEMORYTYPE_DEVICE,&#xA;            .dstMemoryType = CU_MEMORYTYPE_HOST,&#xA;            .srcDevice     = (CUdeviceptr)src->data[i],&#xA;            .dstHost       = dst->data[i],&#xA;            .srcPitch      = src->linesize[i],&#xA;            .dstPitch      = dst->linesize[i],&#xA;            .WidthInBytes  = FFMIN(src->linesize[i], dst->linesize[i]),&#xA;            .Height        = src->height >> (i ? priv->shift_height : 0),&#xA;        };&#xA;&#xA;        ret = CHECK_CU(cu->cuMemcpy2DAsync(&amp;cpy, hwctx->stream));&#xA;        if (ret &lt; 0)&#xA;            goto exit;&#xA;    }&#xA;&#xA;    ret = CHECK_CU(cu->cuStreamSynchronize(hwctx->stream));&#xA;    if (ret &lt; 0)&#xA;        goto exit;&#xA;&#xA;exit:&#xA;    CHECK_CU(cu->cuCtxPopCurrent(&amp;dummy));&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    My questions are :

    &#xA;

      &#xA;
    1. Maybe cuCtxPushCurrent and cuCtxPopCurrent lead to the repeated frames ?
    2. &#xA;

    3. I don't want to use av_hwframe_transfer_data to transfer data to the CPU. How can I do it ?
    4. &#xA;

    &#xA;

  • avcodec/vorbisenc : Combine codebooks, avoid relocations

    7 mai 2021, par Andreas Rheinhardt
    avcodec/vorbisenc : Combine codebooks, avoid relocations
    

    The Vorbis encoder has an array of a structure containing all
    the ingredients for a codebook ; this includes a pointer to
    the actual codebook and some even have a pointer to an array
    containing quant values. Each of these real codebooks is
    an array of its own.
    These pointers lead to relocations and therefore the array will
    be placed in .data.rel.ro and not in .rodata.

    This commit avoids the pointers altogether by combining all the actual
    codebooks into one big array ; the actual codebooks are now accessed
    consecutively by incrementing the pointer used to access them by the
    length of the actual codebook that has just been dealt with (said length
    is contained in the structure describing the codebook). There is
    no downside to this given that these codebooks are already only used
    once during init.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/vorbis_enc_data.h
    • [DH] libavcodec/vorbisenc.c
  • Revert "avcodec : add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common...

    24 décembre 2020, par Andreas Rheinhardt
    Revert "avcodec : add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common_init()"
    

    This mostly reverts commit 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f.
    Said commit removed the freeing code from ff_mpv_common_init(),
    ff_mpv_common_frame_size_change() and ff_mpeg_framesize_alloc() and
    instead added the FF_CODEC_CAP_INIT_CLEANUP to several codecs that use
    ff_mpv_common_init(). This introduced several bugs :

    a) Several decoders using ff_mpv_common_init() in their init function were
    forgotten : This affected FLV, Intel H.263, RealVideo 3.0 and V4.0 as well as
    VC-1/WMV3.
    b) ff_mpv_common_init() is not only called from the init function of
    codecs, it is also called from AVCodec.decode functions. If an error
    happens after an allocation has succeeded, it can lead to memleaks ;
    furthermore, it is now possible for the MpegEncContext to be marked as
    initialized even when ff_mpv_common_init() returns an error and this can
    lead to segfaults because decoders that call ff_mpv_common_init() when
    decoding a frame can mistakenly think that the MpegEncContext has been
    properly initialized. This can e.g. happen with H.261 or MPEG-4.
    c) Removing code for freeing from ff_mpeg_framesize_alloc() (which can't
    be called from any init function) can lead to segfaults because the
    check for whether it needs to allocate consists of checking whether the
    first of the buffers allocated there has been allocated. This part has
    already been fixed in 76cea1d2ce3f23e8131c8664086a1daf873ed694.
    d) ff_mpv_common_frame_size_change() can also not be reached from any
    AVCodec.init function ; yet the changes can e.g. lead to segfaults with
    decoders using ff_h263_decode_frame() upon allocation failure, because
    the MpegEncContext will upon return be flagged as both initialized and
    not in need of reinitialization (granted, the fact that
    ff_h263_decode_frame() clears context_reinit before the context has been
    reinited is a bug in itself). With the earlier version, the context
    would be cleaned upon failure and it would be attempted to initialize
    the context again in the next call to ff_h263_decode_frame().

    While a) could be fixed by adding the missing FF_CODEC_CAP_INIT_CLEANUP,
    keeping the current approach would entail adding cleanup code to several
    other places because of b). Therefore ff_mpv_common_init() is again made
    to clean up after itself ; the changes to the wmv2 decoder and the SVQ1
    encoder have not been reverted : The former fixed a memleak, the latter
    allowed to remove cleanup code.

    Fixes : double free
    Fixes : ff_free_picture_tables.mp4
    Fixes : ff_mpeg_update_thread_context.mp4
    Fixes : decode_colskip.mp4
    Fixes : memset.mp4

    Reviewed-by : Michael Niedermayer <michael@niedermayer.cc>
    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>

    • [DH] libavcodec/h261dec.c
    • [DH] libavcodec/h263dec.c
    • [DH] libavcodec/mpeg12dec.c
    • [DH] libavcodec/mpeg4videodec.c
    • [DH] libavcodec/mpegvideo.c
    • [DH] libavcodec/msmpeg4dec.c
    • [DH] libavcodec/rv10.c