Recherche avancée

Médias (1)

Mot : - Tags -/biomaping

Autres articles (111)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (11095)

  • Failed to compile x264 library for android, error description : clang:error no such file or directory

    12 janvier 2019, par Lee.Saipeng

    I use a shell script to compile the x264 library to the android platform, the architecture is armeabi-v7a,The x264 library was cloned from github。

    I am sure I have those directories,and I checked the search engine such as google,No one encountered the same situation

    ANDROID_NDK=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b
    SYSROOT=$ANDROID_NDK/platforms/android-16/arch-arm
    CROSS_PREFIX=$ANDROID_NDK/toolchains/arm-linux-androideabi-
    4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
    EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -
    D__ANDROID__ -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__"
    EXTRA_LDFLAGS="-nostdlib"
    PREFIX=`pwd`/libs/armeabi-v7a

    ./configure --prefix=$PREFIX \
       --host=arm-linux \
       --sysroot=$SYSROOT \
       --cross-prefix=$CROSS_PREFIX \
       --extra-cflags="$EXTRA_CFLAGS" \
       --extra-ldflags="$EXTRA_LDFLAGS" \
       --enable-pic \
       --enable-static \
       --enable-strip \
       --disable-cli \
       --disable-asm
      # --disable-win32thread \
      # --disable-avs \
      # --disable-swscale \
      # --disable-lavf \
      # --disable-ffms \
      # --disable-gpac \
      # --disable-lsmash \
      # --disable-opencl

    make clean
    make STRIP= -j8 install || exit 1

    cp -f $PREFIX/libx264.a $PREFIX

    The error is here
    enter image description here
    The result is that this x264 library cannot be used. Can someone help me ? thanks very much

    Ok, I generated the config.log file during the compilation of x264, I hope it is an error log file, the log content is as follows :

    checking for -Werror=unknown-warning-option... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__  -Werror=unknown-warning-option   --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -o conftest
    cc1: error: -Werror=unknown-warning-option: no option -Wunknown-warning-option
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    int main (void) {  return 0; }
    --------------------------------------------------
    x264 configure script
    Command line options: "--prefix=/Users/Project/bishe/x264/libs/armeabi-v7a" "--host=arm-linux" "--sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm" "--cross-prefix=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-" "--extra-cflags=-march=armv5te" "-msoft-float" "-D__ANDROID__" "-D__ARM_ARCH_5TE__" "-D__ARM_ARCH_5TEJ__" "--extra-ldflags=-nostdlib" "--enable-pic" "--enable-static" "--enable-strip" "--disable-cli" "--disable-asm" "--disable-win32thread" "--disable-avs" "--disable-swscale" "--disable-lavf" "--disable-ffms" "--disable-gpac" "--disable-lsmash" "--disable-opencl"

    checking whether /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc works... yes
    checking whether /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc supports for( int i = 0; i < 9; i++ ); with -std=gnu99... yes
    checking for pthread_create(0,0,0,0); in pthread.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE  -lpthread   --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:21: fatal error: pthread.h: No such file or directory
    #include
                        ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { pthread_create(0,0,0,0); return 0; }
    --------------------------------------------------
    checking for pthread_create(0,0,0,0); in pthread.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:21: fatal error: pthread.h: No such file or directory
    #include
                        ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { pthread_create(0,0,0,0); return 0; }
    --------------------------------------------------
    checking for log2f(2); in math.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:18: fatal error: math.h: No such file or directory
    #include
                     ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { log2f(2); return 0; }
    --------------------------------------------------
    checking for strtok_r(0, 0, 0); in string.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:20: fatal error: string.h: No such file or directory
    #include
                       ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { strtok_r(0, 0, 0); return 0; }
    --------------------------------------------------
    checking for clock_gettime(CLOCK_MONOTONIC, 0); in time.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:18: fatal error: time.h: No such file or directory
    #include
                     ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { clock_gettime(CLOCK_MONOTONIC, 0); return 0; }
    --------------------------------------------------
    checking for clock_gettime(CLOCK_MONOTONIC, 0); in time.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE  -lrt   --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:18: fatal error: time.h: No such file or directory
    #include
                     ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { clock_gettime(CLOCK_MONOTONIC, 0); return 0; }
    --------------------------------------------------
    checking whether defined(MAP_PRIVATE) is true... no
    --------------------------------------------------
    conftest.c:1:22: fatal error: sys/mman.h: No such file or directory
    #include <sys></sys>mman.h>
                         ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include <sys></sys>mman.h>
    #include
    #if !(defined(MAP_PRIVATE))
    #error  
    #endif
    --------------------------------------------------
    checking for uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3}; in stdint.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    In file included from conftest.c:1:0:
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
    # include_next
                             ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3}; return 0; }
    --------------------------------------------------
    checking for stdio.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC  -shared -Wl,-Bsymbolic   --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -o conftest
    conftest.c:1:19: fatal error: stdio.h: No such file or directory
    #include
                      ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) {  return 0; }
    --------------------------------------------------
    checking for -fno-tree-vectorize... yes
    checking for fseeko(stdin,0,0); in stdio.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -O3 -ffast-math  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -s -o conftest
    conftest.c:1:19: fatal error: stdio.h: No such file or directory
    #include
                      ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { fseeko(stdin,0,0); return 0; }
    --------------------------------------------------
    checking for fseeko64(stdin,0,0); in stdio.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -O3 -ffast-math  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -s -o conftest
    conftest.c:1:19: fatal error: stdio.h: No such file or directory
    #include
                      ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { fseeko64(stdin,0,0); return 0; }
    --------------------------------------------------
    checking for _fseeki64(stdin,0,0); in stdio.h... no
    Failed commandline was:
    --------------------------------------------------
    /Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc conftest.c -O3 -ffast-math  -Wall -I. -I$(SRCPATH) --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -march=armv5te -msoft-float -D__ANDROID__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5TEJ__ -std=gnu99 -D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize     --sysroot=/Users/Project/devtools/android-sdk-macosx/android-ndk-r16b/platforms/android-16/arch-arm -nostdlib -lm -s -o conftest
    conftest.c:1:19: fatal error: stdio.h: No such file or directory
    #include
                      ^
    compilation terminated.
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    #include
    int main (void) { _fseeki64(stdin,0,0); return 0; }
    --------------------------------------------------
    checking for -Wshadow... yes
    checking for -Wmaybe-uninitialized... yes

    platform:      ARM
    byte order:    little-endian
    system:        LINUX
    cli:           no
    libx264:       internal
    shared:        no
    static:        yes
    asm:           no
    interlaced:    yes
    avs:           no
    lavf:          no
    ffms:          no
    mp4:           no
    gpl:           yes
    thread:        no
    opencl:        no
    filters:       crop select_every
    lto:           no
    debug:         no
    gprof:         no
    strip:         yes
    PIC:           yes
    bit depth:     all
    chroma format: all
  • GPÜ-accelerated video processing with ffmpeg

    9 janvier 2019, par Wang Hai

    I want to use ffmpeg to accelerate video encode and decode with an NVIDIA GPU.

    From NVIDIA’s website :

    NVIDIA GPUs contain one or more hardware-based decoder and encoder(s) (separate from the CUDA cores) which provides fully-accelerated hardware-based video decoding and encoding for several popular codecs. With decoding/encoding offloaded, the graphics engine and the CPU are free for other operations.

    My question is : can I use CUDA cores to encode and decode video, maybe faster ?

  • Does H.264 encoded video with BT.709 matrix include any gamma adjustment ?

    27 janvier 2019, par MoDJ

    I have read the BT.709 spec a number of times and the thing that is just not clear is should an encoded H.264 bitstream actually apply any gamma curve to the encoded data ? Note the specific mention of a gamma like formula in the BT.709 spec. Apple provided examples of OpenGL or Metal shaders that read YUV data from CoreVideo provided buffers do not do any sort of gamma adjustment. YUV values are being read and processed as though they are simple linear values. I also examined the source code of ffmpeg and found no gamma adjustments being applied after the BT.709 scaling step. I then created a test video with just two linear grayscale colors 5 and 26 corresponding to 2% and 10% levels. When converted to H.264 with both ffmpeg and iMovie, the output BT.709 values are (YCbCr) (20 128 128) and (38 128 128) and these values exactly match the output of the BT.709 conversion matrix without any gamma adjustment.

    A great piece of background on this topic can be found at Quicktime Gamma Bug. It seems that some historical issues with Quicktime and Adobe encoders were improperly doing different gamma adjustments and the results made video streams look awful on different players. This is really confusing because if you compare to sRGB, it clearly indicates how to apply a gamma encoding and then decode it to convert between sRGB and linear. Why does BT.709 go into so much detail about the same sort of gamma adjustment curve if no gamma adjustment is applied after the matrix step when creating a h.264 data stream ? Are all the color steps in a h.264 stream meant to be coded as straight linear (gamma 1.0) values ?

    In case specific example input would make things more clear, I am attaching 3 color bar images, the exact values of different colors can be displayed in an image editor with these image files.

    This first image is in the sRGB colorspace and is tagged as sRGB.

    sRGB colorspace

    This second image has been converted to the linear RGB colorspace and is tagged with a linear RGB profile.

    linear RGB colorspace

    This third image has been converted to REC.709 profile levels with Rec709-elle-V4-rec709.icc from elles_icc_profiles
    . This seems to be what one would need to do to simulate "camera" gamma as described in BT.709.

    BT.709 colorspace ICC

    Note how the sRGB value in the lower right corner (0x555555) becomes linear RGB (0x171717) and the BT.709 gamma encoded value becomes (0x464646). What is unclear is if I should be passing a linear RGB value into ffmpeg or if I should be passing an already BT.709 gamma encoded value which would then need to be decoded in the client before the linear conversion Matrix step to get back to RGB.

    Update :

    Based on the feedback, I have updated my C based implementation and Metal shader and uploaded to github as an iOS example project MetalBT709Decoder.

    Encoding a normalized linear RGB value is implemented like this :

    static inline
    int BT709_convertLinearRGBToYCbCr(
                               float Rn,
                               float Gn,
                               float Bn,
                               int *YPtr,
                               int *CbPtr,
                               int *CrPtr,
                               int applyGammaMap)
    {
     // Gamma adjustment to non-linear value

     if (applyGammaMap) {
       Rn = BT709_linearNormToNonLinear(Rn);
       Gn = BT709_linearNormToNonLinear(Gn);
       Bn = BT709_linearNormToNonLinear(Bn);
     }

     // https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-6-201506-I!!PDF-E.pdf

     float Ey = (Kr * Rn) + (Kg * Gn) + (Kb * Bn);
     float Eb = (Bn - Ey) / Eb_minus_Ey_Range;
     float Er = (Rn - Ey) / Er_minus_Ey_Range;

     // Quant Y to range [16, 235] (inclusive 219 values)
     // Quant Eb, Er to range [16, 240] (inclusive 224 values, centered at 128)

     float AdjEy = (Ey * (YMax-YMin)) + 16;
     float AdjEb = (Eb * (UVMax-UVMin)) + 128;
     float AdjEr = (Er * (UVMax-UVMin)) + 128;

     *YPtr = (int) round(AdjEy);
     *CbPtr = (int) round(AdjEb);
     *CrPtr = (int) round(AdjEr);

     return 0;
    }

    Decoding from YCbCr to linear RGB is implemented like so :

    static inline
    int BT709_convertYCbCrToLinearRGB(
                                int Y,
                                int Cb,
                                int Cr,
                                float *RPtr,
                                float *GPtr,
                                float *BPtr,
                                int applyGammaMap)
    {
     // https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.709_conversion
     // http://www.niwa.nu/2013/05/understanding-yuv-values/

     // Normalize Y to range [0 255]
     //
     // Note that the matrix multiply will adjust
     // this byte normalized range to account for
     // the limited range [16 235]

     float Yn = (Y - 16) * (1.0f / 255.0f);

     // Normalize Cb and CR with zero at 128 and range [0 255]
     // Note that matrix will adjust to limited range [16 240]

     float Cbn = (Cb - 128) * (1.0f / 255.0f);
     float Crn = (Cr - 128) * (1.0f / 255.0f);

     const float YScale = 255.0f / (YMax-YMin);
     const float UVScale = 255.0f / (UVMax-UVMin);

     const
     float BT709Mat[] = {
       YScale,   0.000f,  (UVScale * Er_minus_Ey_Range),
       YScale, (-1.0f * UVScale * Eb_minus_Ey_Range * Kb_over_Kg),  (-1.0f * UVScale * Er_minus_Ey_Range * Kr_over_Kg),
       YScale, (UVScale * Eb_minus_Ey_Range),  0.000f,
     };

     // Matrix multiply operation
     //
     // rgb = BT709Mat * YCbCr

     // Convert input Y, Cb, Cr to normalized float values

     float Rn = (Yn * BT709Mat[0]) + (Cbn * BT709Mat[1]) + (Crn * BT709Mat[2]);
     float Gn = (Yn * BT709Mat[3]) + (Cbn * BT709Mat[4]) + (Crn * BT709Mat[5]);
     float Bn = (Yn * BT709Mat[6]) + (Cbn * BT709Mat[7]) + (Crn * BT709Mat[8]);

     // Saturate normalzied linear (R G B) to range [0.0, 1.0]

     Rn = saturatef(Rn);
     Gn = saturatef(Gn);
     Bn = saturatef(Bn);

     // Gamma adjustment for RGB components after matrix transform

     if (applyGammaMap) {
       Rn = BT709_nonLinearNormToLinear(Rn);
       Gn = BT709_nonLinearNormToLinear(Gn);
       Bn = BT709_nonLinearNormToLinear(Bn);
     }

     *RPtr = Rn;
     *GPtr = Gn;
     *BPtr = Bn;

     return 0;
    }

    I believe this logic is implemented correctly, but I am having a very difficult time validating the results. When I generate a .m4v file that contains gamma adjusted color values (osxcolor_test_image_24bit_BT709.m4v), the result come out as expected. But a test case like (bars_709_Frame01.m4v) that I found here does not seem to work as the color bar values seem to be encoded as linear (no gamma adjustment).

    For a SMPTE test pattern, the 0.75 graylevel is linear RGB (191 191 191), should this RGB be encoded with no gamma adjustment as (Y Cb Cr) (180 128 128) or should the value in the bitstream appear as the gamma adjusted (Y Cb Cr) (206 128 128) ?

    (follow up)
    After doing additional research into this gamma issue, it has become clear that what Apple is actually doing in AVFoundation is using a 1.961 gamma function. This is the case when encoding with AVAssetWriterInputPixelBufferAdaptor, when using vImage, or with CoreVideo APIs. This piecewise gamma function is defined as follows :

    #define APPLE_GAMMA_196 (1.960938f)

    static inline
    float Apple196_nonLinearNormToLinear(float normV) {
     const float xIntercept = 0.05583828f;

     if (normV &lt; xIntercept) {
       normV *= (1.0f / 16.0f);
     } else {
       const float gamma = APPLE_GAMMA_196;
       normV = pow(normV, gamma);
     }

     return normV;
    }

    static inline
    float Apple196_linearNormToNonLinear(float normV) {
     const float yIntercept = 0.00349f;

     if (normV &lt; yIntercept) {
       normV *= 16.0f;
     } else {
       const float gamma = 1.0f / APPLE_GAMMA_196;
       normV = pow(normV, gamma);
     }

     return normV;
    }